
obj/user/testfdsharing:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 cf 03 00 00       	call   800400 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <umain>:

char buf[512], buf2[512];

void
umain(void)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	57                   	push   %edi
  800038:	56                   	push   %esi
  800039:	53                   	push   %ebx
  80003a:	83 ec 2c             	sub    $0x2c,%esp
	int fd, r, n, n2;

	if ((fd = open("motd", O_RDONLY)) < 0)
  80003d:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800044:	00 
  800045:	c7 04 24 0c 31 80 00 	movl   $0x80310c,(%esp)
  80004c:	e8 bb 20 00 00       	call   80210c <open>
  800051:	89 c3                	mov    %eax,%ebx
  800053:	85 c0                	test   %eax,%eax
  800055:	79 20                	jns    800077 <umain+0x43>
		panic("open motd: %e", fd);
  800057:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80005b:	c7 44 24 08 a0 30 80 	movl   $0x8030a0,0x8(%esp)
  800062:	00 
  800063:	c7 44 24 04 0c 00 00 	movl   $0xc,0x4(%esp)
  80006a:	00 
  80006b:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  800072:	e8 f5 03 00 00       	call   80046c <_panic>
	seek(fd, 0);
  800077:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80007e:	00 
  80007f:	89 04 24             	mov    %eax,(%esp)
  800082:	e8 de 18 00 00       	call   801965 <seek>
	if ((n = readn(fd, buf, sizeof buf)) <= 0)
  800087:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  80008e:	00 
  80008f:	c7 44 24 04 80 72 80 	movl   $0x807280,0x4(%esp)
  800096:	00 
  800097:	89 1c 24             	mov    %ebx,(%esp)
  80009a:	e8 c2 1b 00 00       	call   801c61 <readn>
  80009f:	89 c7                	mov    %eax,%edi
  8000a1:	85 c0                	test   %eax,%eax
  8000a3:	7f 20                	jg     8000c5 <umain+0x91>
		panic("readn: %e", n);
  8000a5:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8000a9:	c7 44 24 08 c3 30 80 	movl   $0x8030c3,0x8(%esp)
  8000b0:	00 
  8000b1:	c7 44 24 04 0f 00 00 	movl   $0xf,0x4(%esp)
  8000b8:	00 
  8000b9:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  8000c0:	e8 a7 03 00 00       	call   80046c <_panic>

	if ((r = fork()) < 0)
  8000c5:	e8 d8 13 00 00       	call   8014a2 <fork>
  8000ca:	89 c6                	mov    %eax,%esi
  8000cc:	85 c0                	test   %eax,%eax
  8000ce:	79 20                	jns    8000f0 <umain+0xbc>
		panic("fork: %e", r);
  8000d0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8000d4:	c7 44 24 08 cd 30 80 	movl   $0x8030cd,0x8(%esp)
  8000db:	00 
  8000dc:	c7 44 24 04 12 00 00 	movl   $0x12,0x4(%esp)
  8000e3:	00 
  8000e4:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  8000eb:	e8 7c 03 00 00       	call   80046c <_panic>
	if (r == 0) {
  8000f0:	85 c0                	test   %eax,%eax
  8000f2:	0f 85 bd 00 00 00    	jne    8001b5 <umain+0x181>
		seek(fd, 0);
  8000f8:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8000ff:	00 
  800100:	89 1c 24             	mov    %ebx,(%esp)
  800103:	e8 5d 18 00 00       	call   801965 <seek>
		cprintf("going to read in child (might page fault if your sharing is buggy)\n");
  800108:	c7 04 24 b4 31 80 00 	movl   $0x8031b4,(%esp)
  80010f:	e8 1d 04 00 00       	call   800531 <cprintf>
		if ((n2 = readn(fd, buf2, sizeof buf2)) != n)
  800114:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  80011b:	00 
  80011c:	c7 44 24 04 80 70 80 	movl   $0x807080,0x4(%esp)
  800123:	00 
  800124:	89 1c 24             	mov    %ebx,(%esp)
  800127:	e8 35 1b 00 00       	call   801c61 <readn>
  80012c:	39 c7                	cmp    %eax,%edi
  80012e:	74 24                	je     800154 <umain+0x120>
			panic("read in parent got %d, read in child got %d", n, n2);
  800130:	89 44 24 10          	mov    %eax,0x10(%esp)
  800134:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  800138:	c7 44 24 08 f8 31 80 	movl   $0x8031f8,0x8(%esp)
  80013f:	00 
  800140:	c7 44 24 04 17 00 00 	movl   $0x17,0x4(%esp)
  800147:	00 
  800148:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  80014f:	e8 18 03 00 00       	call   80046c <_panic>
		if (memcmp(buf, buf2, n) != 0)
  800154:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800158:	c7 44 24 04 80 70 80 	movl   $0x807080,0x4(%esp)
  80015f:	00 
  800160:	c7 04 24 80 72 80 00 	movl   $0x807280,(%esp)
  800167:	e8 e6 0c 00 00       	call   800e52 <memcmp>
  80016c:	85 c0                	test   %eax,%eax
  80016e:	74 1c                	je     80018c <umain+0x158>
			panic("read in parent got different bytes from read in child");
  800170:	c7 44 24 08 24 32 80 	movl   $0x803224,0x8(%esp)
  800177:	00 
  800178:	c7 44 24 04 19 00 00 	movl   $0x19,0x4(%esp)
  80017f:	00 
  800180:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  800187:	e8 e0 02 00 00       	call   80046c <_panic>
		cprintf("read in child succeeded\n");
  80018c:	c7 04 24 d6 30 80 00 	movl   $0x8030d6,(%esp)
  800193:	e8 99 03 00 00       	call   800531 <cprintf>
		seek(fd, 0);
  800198:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80019f:	00 
  8001a0:	89 1c 24             	mov    %ebx,(%esp)
  8001a3:	e8 bd 17 00 00       	call   801965 <seek>
		close(fd);
  8001a8:	89 1c 24             	mov    %ebx,(%esp)
  8001ab:	e8 8c 1b 00 00       	call   801d3c <close>
		exit();
  8001b0:	e8 9b 02 00 00       	call   800450 <exit>
	}
	wait(r);
  8001b5:	89 34 24             	mov    %esi,(%esp)
  8001b8:	e8 97 28 00 00       	call   802a54 <wait>
	if ((n2 = readn(fd, buf2, sizeof buf2)) != n)
  8001bd:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  8001c4:	00 
  8001c5:	c7 44 24 04 80 70 80 	movl   $0x807080,0x4(%esp)
  8001cc:	00 
  8001cd:	89 1c 24             	mov    %ebx,(%esp)
  8001d0:	e8 8c 1a 00 00       	call   801c61 <readn>
  8001d5:	39 c7                	cmp    %eax,%edi
  8001d7:	74 24                	je     8001fd <umain+0x1c9>
		panic("read in parent got %d, then got %d", n, n2);
  8001d9:	89 44 24 10          	mov    %eax,0x10(%esp)
  8001dd:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  8001e1:	c7 44 24 08 5c 32 80 	movl   $0x80325c,0x8(%esp)
  8001e8:	00 
  8001e9:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  8001f0:	00 
  8001f1:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  8001f8:	e8 6f 02 00 00       	call   80046c <_panic>
	cprintf("read in parent succeeded\n");		
  8001fd:	c7 04 24 ef 30 80 00 	movl   $0x8030ef,(%esp)
  800204:	e8 28 03 00 00       	call   800531 <cprintf>
	close(fd);
  800209:	89 1c 24             	mov    %ebx,(%esp)
  80020c:	e8 2b 1b 00 00       	call   801d3c <close>

	if ((fd = open("newmotd", O_RDWR)) < 0)
  800211:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
  800218:	00 
  800219:	c7 04 24 09 31 80 00 	movl   $0x803109,(%esp)
  800220:	e8 e7 1e 00 00       	call   80210c <open>
  800225:	89 c3                	mov    %eax,%ebx
  800227:	85 c0                	test   %eax,%eax
  800229:	79 20                	jns    80024b <umain+0x217>
		panic("open newmotd: %e", fd);
  80022b:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80022f:	c7 44 24 08 11 31 80 	movl   $0x803111,0x8(%esp)
  800236:	00 
  800237:	c7 44 24 04 26 00 00 	movl   $0x26,0x4(%esp)
  80023e:	00 
  80023f:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  800246:	e8 21 02 00 00       	call   80046c <_panic>
	seek(fd, 0);
  80024b:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800252:	00 
  800253:	89 04 24             	mov    %eax,(%esp)
  800256:	e8 0a 17 00 00       	call   801965 <seek>
	if ((n = write(fd, "hello", 5)) != 5)
  80025b:	c7 44 24 08 05 00 00 	movl   $0x5,0x8(%esp)
  800262:	00 
  800263:	c7 44 24 04 22 31 80 	movl   $0x803122,0x4(%esp)
  80026a:	00 
  80026b:	89 1c 24             	mov    %ebx,(%esp)
  80026e:	e8 87 18 00 00       	call   801afa <write>
  800273:	83 f8 05             	cmp    $0x5,%eax
  800276:	74 20                	je     800298 <umain+0x264>
		panic("write: %e", n);
  800278:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80027c:	c7 44 24 08 28 31 80 	movl   $0x803128,0x8(%esp)
  800283:	00 
  800284:	c7 44 24 04 29 00 00 	movl   $0x29,0x4(%esp)
  80028b:	00 
  80028c:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  800293:	e8 d4 01 00 00       	call   80046c <_panic>

	if ((r = fork()) < 0)
  800298:	e8 05 12 00 00       	call   8014a2 <fork>
  80029d:	89 c6                	mov    %eax,%esi
  80029f:	85 c0                	test   %eax,%eax
  8002a1:	79 20                	jns    8002c3 <umain+0x28f>
		panic("fork: %e", r);
  8002a3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8002a7:	c7 44 24 08 cd 30 80 	movl   $0x8030cd,0x8(%esp)
  8002ae:	00 
  8002af:	c7 44 24 04 2c 00 00 	movl   $0x2c,0x4(%esp)
  8002b6:	00 
  8002b7:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  8002be:	e8 a9 01 00 00       	call   80046c <_panic>
	if (r == 0) {
  8002c3:	85 c0                	test   %eax,%eax
  8002c5:	75 72                	jne    800339 <umain+0x305>
		seek(fd, 0);
  8002c7:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8002ce:	00 
  8002cf:	89 1c 24             	mov    %ebx,(%esp)
  8002d2:	e8 8e 16 00 00       	call   801965 <seek>
		cprintf("going to write in child\n");
  8002d7:	c7 04 24 32 31 80 00 	movl   $0x803132,(%esp)
  8002de:	e8 4e 02 00 00       	call   800531 <cprintf>
		if ((n = write(fd, "world", 5)) != 5)
  8002e3:	c7 44 24 08 05 00 00 	movl   $0x5,0x8(%esp)
  8002ea:	00 
  8002eb:	c7 44 24 04 4b 31 80 	movl   $0x80314b,0x4(%esp)
  8002f2:	00 
  8002f3:	89 1c 24             	mov    %ebx,(%esp)
  8002f6:	e8 ff 17 00 00       	call   801afa <write>
  8002fb:	83 f8 05             	cmp    $0x5,%eax
  8002fe:	74 20                	je     800320 <umain+0x2ec>
			panic("write in child: %e", n);
  800300:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800304:	c7 44 24 08 51 31 80 	movl   $0x803151,0x8(%esp)
  80030b:	00 
  80030c:	c7 44 24 04 31 00 00 	movl   $0x31,0x4(%esp)
  800313:	00 
  800314:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  80031b:	e8 4c 01 00 00       	call   80046c <_panic>
		cprintf("write in child finished\n");
  800320:	c7 04 24 64 31 80 00 	movl   $0x803164,(%esp)
  800327:	e8 05 02 00 00       	call   800531 <cprintf>
		close(fd);
  80032c:	89 1c 24             	mov    %ebx,(%esp)
  80032f:	e8 08 1a 00 00       	call   801d3c <close>
		exit();
  800334:	e8 17 01 00 00       	call   800450 <exit>
	}
	wait(r);
  800339:	89 34 24             	mov    %esi,(%esp)
  80033c:	e8 13 27 00 00       	call   802a54 <wait>
	seek(fd, 0);
  800341:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800348:	00 
  800349:	89 1c 24             	mov    %ebx,(%esp)
  80034c:	e8 14 16 00 00       	call   801965 <seek>
	if ((n = readn(fd, buf, 5)) != 5)
  800351:	c7 44 24 08 05 00 00 	movl   $0x5,0x8(%esp)
  800358:	00 
  800359:	c7 44 24 04 80 72 80 	movl   $0x807280,0x4(%esp)
  800360:	00 
  800361:	89 1c 24             	mov    %ebx,(%esp)
  800364:	e8 f8 18 00 00       	call   801c61 <readn>
  800369:	83 f8 05             	cmp    $0x5,%eax
  80036c:	74 20                	je     80038e <umain+0x35a>
		panic("readn: %e", n);
  80036e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800372:	c7 44 24 08 c3 30 80 	movl   $0x8030c3,0x8(%esp)
  800379:	00 
  80037a:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  800381:	00 
  800382:	c7 04 24 ae 30 80 00 	movl   $0x8030ae,(%esp)
  800389:	e8 de 00 00 00       	call   80046c <_panic>
	buf[5] = 0;
  80038e:	c6 05 85 72 80 00 00 	movb   $0x0,0x807285
	if (strcmp(buf, "hello") == 0)
  800395:	c7 44 24 04 22 31 80 	movl   $0x803122,0x4(%esp)
  80039c:	00 
  80039d:	c7 04 24 80 72 80 00 	movl   $0x807280,(%esp)
  8003a4:	e8 e0 08 00 00       	call   800c89 <strcmp>
  8003a9:	85 c0                	test   %eax,%eax
  8003ab:	75 0e                	jne    8003bb <umain+0x387>
		cprintf("write to file failed; got old data\n");
  8003ad:	c7 04 24 80 32 80 00 	movl   $0x803280,(%esp)
  8003b4:	e8 78 01 00 00       	call   800531 <cprintf>
  8003b9:	eb 3a                	jmp    8003f5 <umain+0x3c1>
	else if (strcmp(buf, "world") == 0)
  8003bb:	c7 44 24 04 4b 31 80 	movl   $0x80314b,0x4(%esp)
  8003c2:	00 
  8003c3:	c7 04 24 80 72 80 00 	movl   $0x807280,(%esp)
  8003ca:	e8 ba 08 00 00       	call   800c89 <strcmp>
  8003cf:	85 c0                	test   %eax,%eax
  8003d1:	75 0e                	jne    8003e1 <umain+0x3ad>
		cprintf("write to file succeeded\n");
  8003d3:	c7 04 24 7d 31 80 00 	movl   $0x80317d,(%esp)
  8003da:	e8 52 01 00 00       	call   800531 <cprintf>
  8003df:	eb 14                	jmp    8003f5 <umain+0x3c1>
	else
		cprintf("write to file failed; got %s\n", buf);
  8003e1:	c7 44 24 04 80 72 80 	movl   $0x807280,0x4(%esp)
  8003e8:	00 
  8003e9:	c7 04 24 96 31 80 00 	movl   $0x803196,(%esp)
  8003f0:	e8 3c 01 00 00       	call   800531 <cprintf>
static __inline uint64_t read_tsc(void) __attribute__((always_inline));

static __inline void
breakpoint(void)
{
	__asm __volatile("int3");
  8003f5:	cc                   	int3   

	breakpoint();
}
  8003f6:	83 c4 2c             	add    $0x2c,%esp
  8003f9:	5b                   	pop    %ebx
  8003fa:	5e                   	pop    %esi
  8003fb:	5f                   	pop    %edi
  8003fc:	5d                   	pop    %ebp
  8003fd:	c3                   	ret    
	...

00800400 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800400:	55                   	push   %ebp
  800401:	89 e5                	mov    %esp,%ebp
  800403:	83 ec 18             	sub    $0x18,%esp
  800406:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800409:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80040c:	8b 75 08             	mov    0x8(%ebp),%esi
  80040f:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  800412:	e8 d2 0f 00 00       	call   8013e9 <sys_getenvid>
	env = &envs [ENVX(envid)];
  800417:	25 ff 03 00 00       	and    $0x3ff,%eax
  80041c:	6b c0 7c             	imul   $0x7c,%eax,%eax
  80041f:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800424:	a3 80 74 80 00       	mov    %eax,0x807480

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800429:	85 f6                	test   %esi,%esi
  80042b:	7e 07                	jle    800434 <libmain+0x34>
		binaryname = argv[0];
  80042d:	8b 03                	mov    (%ebx),%eax
  80042f:	a3 00 70 80 00       	mov    %eax,0x807000

	// call user main routine
	umain(argc, argv);
  800434:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800438:	89 34 24             	mov    %esi,(%esp)
  80043b:	e8 f4 fb ff ff       	call   800034 <umain>

	// exit gracefully
	exit();
  800440:	e8 0b 00 00 00       	call   800450 <exit>
}
  800445:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800448:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80044b:	89 ec                	mov    %ebp,%esp
  80044d:	5d                   	pop    %ebp
  80044e:	c3                   	ret    
	...

00800450 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800450:	55                   	push   %ebp
  800451:	89 e5                	mov    %esp,%ebp
  800453:	83 ec 18             	sub    $0x18,%esp
	close_all();
  800456:	e8 5e 19 00 00       	call   801db9 <close_all>
	sys_env_destroy(0);
  80045b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800462:	e8 b6 0f 00 00       	call   80141d <sys_env_destroy>
}
  800467:	c9                   	leave  
  800468:	c3                   	ret    
  800469:	00 00                	add    %al,(%eax)
	...

0080046c <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  80046c:	55                   	push   %ebp
  80046d:	89 e5                	mov    %esp,%ebp
  80046f:	53                   	push   %ebx
  800470:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800473:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  800476:	a1 84 74 80 00       	mov    0x807484,%eax
  80047b:	85 c0                	test   %eax,%eax
  80047d:	74 10                	je     80048f <_panic+0x23>
		cprintf("%s: ", argv0);
  80047f:	89 44 24 04          	mov    %eax,0x4(%esp)
  800483:	c7 04 24 bb 32 80 00 	movl   $0x8032bb,(%esp)
  80048a:	e8 a2 00 00 00       	call   800531 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  80048f:	8b 45 0c             	mov    0xc(%ebp),%eax
  800492:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800496:	8b 45 08             	mov    0x8(%ebp),%eax
  800499:	89 44 24 08          	mov    %eax,0x8(%esp)
  80049d:	a1 00 70 80 00       	mov    0x807000,%eax
  8004a2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8004a6:	c7 04 24 c0 32 80 00 	movl   $0x8032c0,(%esp)
  8004ad:	e8 7f 00 00 00       	call   800531 <cprintf>
	vcprintf(fmt, ap);
  8004b2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8004b6:	8b 45 10             	mov    0x10(%ebp),%eax
  8004b9:	89 04 24             	mov    %eax,(%esp)
  8004bc:	e8 0f 00 00 00       	call   8004d0 <vcprintf>
	cprintf("\n");
  8004c1:	c7 04 24 47 36 80 00 	movl   $0x803647,(%esp)
  8004c8:	e8 64 00 00 00       	call   800531 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  8004cd:	cc                   	int3   
  8004ce:	eb fd                	jmp    8004cd <_panic+0x61>

008004d0 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  8004d0:	55                   	push   %ebp
  8004d1:	89 e5                	mov    %esp,%ebp
  8004d3:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  8004d9:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8004e0:	00 00 00 
	b.cnt = 0;
  8004e3:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  8004ea:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  8004ed:	8b 45 0c             	mov    0xc(%ebp),%eax
  8004f0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8004f4:	8b 45 08             	mov    0x8(%ebp),%eax
  8004f7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8004fb:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800501:	89 44 24 04          	mov    %eax,0x4(%esp)
  800505:	c7 04 24 4b 05 80 00 	movl   $0x80054b,(%esp)
  80050c:	e8 cc 01 00 00       	call   8006dd <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800511:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  800517:	89 44 24 04          	mov    %eax,0x4(%esp)
  80051b:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800521:	89 04 24             	mov    %eax,(%esp)
  800524:	e8 c7 0a 00 00       	call   800ff0 <sys_cputs>

	return b.cnt;
}
  800529:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  80052f:	c9                   	leave  
  800530:	c3                   	ret    

00800531 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800531:	55                   	push   %ebp
  800532:	89 e5                	mov    %esp,%ebp
  800534:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  800537:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  80053a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80053e:	8b 45 08             	mov    0x8(%ebp),%eax
  800541:	89 04 24             	mov    %eax,(%esp)
  800544:	e8 87 ff ff ff       	call   8004d0 <vcprintf>
	va_end(ap);

	return cnt;
}
  800549:	c9                   	leave  
  80054a:	c3                   	ret    

0080054b <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  80054b:	55                   	push   %ebp
  80054c:	89 e5                	mov    %esp,%ebp
  80054e:	53                   	push   %ebx
  80054f:	83 ec 14             	sub    $0x14,%esp
  800552:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800555:	8b 03                	mov    (%ebx),%eax
  800557:	8b 55 08             	mov    0x8(%ebp),%edx
  80055a:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  80055e:	83 c0 01             	add    $0x1,%eax
  800561:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800563:	3d ff 00 00 00       	cmp    $0xff,%eax
  800568:	75 19                	jne    800583 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  80056a:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800571:	00 
  800572:	8d 43 08             	lea    0x8(%ebx),%eax
  800575:	89 04 24             	mov    %eax,(%esp)
  800578:	e8 73 0a 00 00       	call   800ff0 <sys_cputs>
		b->idx = 0;
  80057d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800583:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  800587:	83 c4 14             	add    $0x14,%esp
  80058a:	5b                   	pop    %ebx
  80058b:	5d                   	pop    %ebp
  80058c:	c3                   	ret    
  80058d:	00 00                	add    %al,(%eax)
	...

00800590 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800590:	55                   	push   %ebp
  800591:	89 e5                	mov    %esp,%ebp
  800593:	57                   	push   %edi
  800594:	56                   	push   %esi
  800595:	53                   	push   %ebx
  800596:	83 ec 4c             	sub    $0x4c,%esp
  800599:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80059c:	89 d6                	mov    %edx,%esi
  80059e:	8b 45 08             	mov    0x8(%ebp),%eax
  8005a1:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8005a4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8005a7:	89 55 e0             	mov    %edx,-0x20(%ebp)
  8005aa:	8b 45 10             	mov    0x10(%ebp),%eax
  8005ad:	8b 5d 14             	mov    0x14(%ebp),%ebx
  8005b0:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  8005b3:	89 45 dc             	mov    %eax,-0x24(%ebp)
  8005b6:	b9 00 00 00 00       	mov    $0x0,%ecx
  8005bb:	39 d1                	cmp    %edx,%ecx
  8005bd:	72 15                	jb     8005d4 <printnum+0x44>
  8005bf:	77 07                	ja     8005c8 <printnum+0x38>
  8005c1:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8005c4:	39 d0                	cmp    %edx,%eax
  8005c6:	76 0c                	jbe    8005d4 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8005c8:	83 eb 01             	sub    $0x1,%ebx
  8005cb:	85 db                	test   %ebx,%ebx
  8005cd:	8d 76 00             	lea    0x0(%esi),%esi
  8005d0:	7f 61                	jg     800633 <printnum+0xa3>
  8005d2:	eb 70                	jmp    800644 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  8005d4:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8005d8:	83 eb 01             	sub    $0x1,%ebx
  8005db:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8005df:	89 44 24 08          	mov    %eax,0x8(%esp)
  8005e3:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8005e7:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  8005eb:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8005ee:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  8005f1:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8005f4:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8005f8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8005ff:	00 
  800600:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800603:	89 04 24             	mov    %eax,(%esp)
  800606:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800609:	89 54 24 04          	mov    %edx,0x4(%esp)
  80060d:	e8 0e 28 00 00       	call   802e20 <__udivdi3>
  800612:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800615:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  800618:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80061c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800620:	89 04 24             	mov    %eax,(%esp)
  800623:	89 54 24 04          	mov    %edx,0x4(%esp)
  800627:	89 f2                	mov    %esi,%edx
  800629:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80062c:	e8 5f ff ff ff       	call   800590 <printnum>
  800631:	eb 11                	jmp    800644 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800633:	89 74 24 04          	mov    %esi,0x4(%esp)
  800637:	89 3c 24             	mov    %edi,(%esp)
  80063a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80063d:	83 eb 01             	sub    $0x1,%ebx
  800640:	85 db                	test   %ebx,%ebx
  800642:	7f ef                	jg     800633 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800644:	89 74 24 04          	mov    %esi,0x4(%esp)
  800648:	8b 74 24 04          	mov    0x4(%esp),%esi
  80064c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80064f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800653:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80065a:	00 
  80065b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80065e:	89 14 24             	mov    %edx,(%esp)
  800661:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800664:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800668:	e8 e3 28 00 00       	call   802f50 <__umoddi3>
  80066d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800671:	0f be 80 dc 32 80 00 	movsbl 0x8032dc(%eax),%eax
  800678:	89 04 24             	mov    %eax,(%esp)
  80067b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80067e:	83 c4 4c             	add    $0x4c,%esp
  800681:	5b                   	pop    %ebx
  800682:	5e                   	pop    %esi
  800683:	5f                   	pop    %edi
  800684:	5d                   	pop    %ebp
  800685:	c3                   	ret    

00800686 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800686:	55                   	push   %ebp
  800687:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800689:	83 fa 01             	cmp    $0x1,%edx
  80068c:	7e 0e                	jle    80069c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80068e:	8b 10                	mov    (%eax),%edx
  800690:	8d 4a 08             	lea    0x8(%edx),%ecx
  800693:	89 08                	mov    %ecx,(%eax)
  800695:	8b 02                	mov    (%edx),%eax
  800697:	8b 52 04             	mov    0x4(%edx),%edx
  80069a:	eb 22                	jmp    8006be <getuint+0x38>
	else if (lflag)
  80069c:	85 d2                	test   %edx,%edx
  80069e:	74 10                	je     8006b0 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  8006a0:	8b 10                	mov    (%eax),%edx
  8006a2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8006a5:	89 08                	mov    %ecx,(%eax)
  8006a7:	8b 02                	mov    (%edx),%eax
  8006a9:	ba 00 00 00 00       	mov    $0x0,%edx
  8006ae:	eb 0e                	jmp    8006be <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  8006b0:	8b 10                	mov    (%eax),%edx
  8006b2:	8d 4a 04             	lea    0x4(%edx),%ecx
  8006b5:	89 08                	mov    %ecx,(%eax)
  8006b7:	8b 02                	mov    (%edx),%eax
  8006b9:	ba 00 00 00 00       	mov    $0x0,%edx
}
  8006be:	5d                   	pop    %ebp
  8006bf:	c3                   	ret    

008006c0 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8006c0:	55                   	push   %ebp
  8006c1:	89 e5                	mov    %esp,%ebp
  8006c3:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8006c6:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8006ca:	8b 10                	mov    (%eax),%edx
  8006cc:	3b 50 04             	cmp    0x4(%eax),%edx
  8006cf:	73 0a                	jae    8006db <sprintputch+0x1b>
		*b->buf++ = ch;
  8006d1:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8006d4:	88 0a                	mov    %cl,(%edx)
  8006d6:	83 c2 01             	add    $0x1,%edx
  8006d9:	89 10                	mov    %edx,(%eax)
}
  8006db:	5d                   	pop    %ebp
  8006dc:	c3                   	ret    

008006dd <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  8006dd:	55                   	push   %ebp
  8006de:	89 e5                	mov    %esp,%ebp
  8006e0:	57                   	push   %edi
  8006e1:	56                   	push   %esi
  8006e2:	53                   	push   %ebx
  8006e3:	83 ec 5c             	sub    $0x5c,%esp
  8006e6:	8b 7d 08             	mov    0x8(%ebp),%edi
  8006e9:	8b 75 0c             	mov    0xc(%ebp),%esi
  8006ec:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  8006ef:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  8006f6:	eb 11                	jmp    800709 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  8006f8:	85 c0                	test   %eax,%eax
  8006fa:	0f 84 f9 03 00 00    	je     800af9 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  800700:	89 74 24 04          	mov    %esi,0x4(%esp)
  800704:	89 04 24             	mov    %eax,(%esp)
  800707:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800709:	0f b6 03             	movzbl (%ebx),%eax
  80070c:	83 c3 01             	add    $0x1,%ebx
  80070f:	83 f8 25             	cmp    $0x25,%eax
  800712:	75 e4                	jne    8006f8 <vprintfmt+0x1b>
  800714:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  800718:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80071f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  800726:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  80072d:	b9 00 00 00 00       	mov    $0x0,%ecx
  800732:	eb 06                	jmp    80073a <vprintfmt+0x5d>
  800734:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800738:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80073a:	0f b6 13             	movzbl (%ebx),%edx
  80073d:	0f b6 c2             	movzbl %dl,%eax
  800740:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800743:	8d 43 01             	lea    0x1(%ebx),%eax
  800746:	83 ea 23             	sub    $0x23,%edx
  800749:	80 fa 55             	cmp    $0x55,%dl
  80074c:	0f 87 8a 03 00 00    	ja     800adc <vprintfmt+0x3ff>
  800752:	0f b6 d2             	movzbl %dl,%edx
  800755:	ff 24 95 20 34 80 00 	jmp    *0x803420(,%edx,4)
  80075c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800760:	eb d6                	jmp    800738 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800762:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800765:	83 ea 30             	sub    $0x30,%edx
  800768:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80076b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80076e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800771:	83 fb 09             	cmp    $0x9,%ebx
  800774:	77 54                	ja     8007ca <vprintfmt+0xed>
  800776:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800779:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80077c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80077f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800782:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800786:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800789:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80078c:	83 fb 09             	cmp    $0x9,%ebx
  80078f:	76 eb                	jbe    80077c <vprintfmt+0x9f>
  800791:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800794:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800797:	eb 31                	jmp    8007ca <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800799:	8b 55 14             	mov    0x14(%ebp),%edx
  80079c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80079f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  8007a2:	8b 12                	mov    (%edx),%edx
  8007a4:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  8007a7:	eb 21                	jmp    8007ca <vprintfmt+0xed>

		case '.':
			if (width < 0)
  8007a9:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8007ad:	ba 00 00 00 00       	mov    $0x0,%edx
  8007b2:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  8007b6:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8007b9:	e9 7a ff ff ff       	jmp    800738 <vprintfmt+0x5b>
  8007be:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  8007c5:	e9 6e ff ff ff       	jmp    800738 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  8007ca:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8007ce:	0f 89 64 ff ff ff    	jns    800738 <vprintfmt+0x5b>
  8007d4:	8b 55 d0             	mov    -0x30(%ebp),%edx
  8007d7:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8007da:	8b 55 c8             	mov    -0x38(%ebp),%edx
  8007dd:	89 55 d0             	mov    %edx,-0x30(%ebp)
  8007e0:	e9 53 ff ff ff       	jmp    800738 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  8007e5:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  8007e8:	e9 4b ff ff ff       	jmp    800738 <vprintfmt+0x5b>
  8007ed:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  8007f0:	8b 45 14             	mov    0x14(%ebp),%eax
  8007f3:	8d 50 04             	lea    0x4(%eax),%edx
  8007f6:	89 55 14             	mov    %edx,0x14(%ebp)
  8007f9:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007fd:	8b 00                	mov    (%eax),%eax
  8007ff:	89 04 24             	mov    %eax,(%esp)
  800802:	ff d7                	call   *%edi
  800804:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800807:	e9 fd fe ff ff       	jmp    800709 <vprintfmt+0x2c>
  80080c:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  80080f:	8b 45 14             	mov    0x14(%ebp),%eax
  800812:	8d 50 04             	lea    0x4(%eax),%edx
  800815:	89 55 14             	mov    %edx,0x14(%ebp)
  800818:	8b 00                	mov    (%eax),%eax
  80081a:	89 c2                	mov    %eax,%edx
  80081c:	c1 fa 1f             	sar    $0x1f,%edx
  80081f:	31 d0                	xor    %edx,%eax
  800821:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800823:	83 f8 12             	cmp    $0x12,%eax
  800826:	7f 0b                	jg     800833 <vprintfmt+0x156>
  800828:	8b 14 85 80 35 80 00 	mov    0x803580(,%eax,4),%edx
  80082f:	85 d2                	test   %edx,%edx
  800831:	75 20                	jne    800853 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800833:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800837:	c7 44 24 08 ed 32 80 	movl   $0x8032ed,0x8(%esp)
  80083e:	00 
  80083f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800843:	89 3c 24             	mov    %edi,(%esp)
  800846:	e8 36 03 00 00       	call   800b81 <printfmt>
  80084b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  80084e:	e9 b6 fe ff ff       	jmp    800709 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800853:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800857:	c7 44 24 08 92 38 80 	movl   $0x803892,0x8(%esp)
  80085e:	00 
  80085f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800863:	89 3c 24             	mov    %edi,(%esp)
  800866:	e8 16 03 00 00       	call   800b81 <printfmt>
  80086b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80086e:	e9 96 fe ff ff       	jmp    800709 <vprintfmt+0x2c>
  800873:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800876:	89 c3                	mov    %eax,%ebx
  800878:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80087b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80087e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800881:	8b 45 14             	mov    0x14(%ebp),%eax
  800884:	8d 50 04             	lea    0x4(%eax),%edx
  800887:	89 55 14             	mov    %edx,0x14(%ebp)
  80088a:	8b 00                	mov    (%eax),%eax
  80088c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80088f:	85 c0                	test   %eax,%eax
  800891:	b8 f6 32 80 00       	mov    $0x8032f6,%eax
  800896:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80089a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80089d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  8008a1:	7e 06                	jle    8008a9 <vprintfmt+0x1cc>
  8008a3:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  8008a7:	75 13                	jne    8008bc <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8008a9:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8008ac:	0f be 02             	movsbl (%edx),%eax
  8008af:	85 c0                	test   %eax,%eax
  8008b1:	0f 85 9b 00 00 00    	jne    800952 <vprintfmt+0x275>
  8008b7:	e9 88 00 00 00       	jmp    800944 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8008bc:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  8008c0:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8008c3:	89 0c 24             	mov    %ecx,(%esp)
  8008c6:	e8 00 03 00 00       	call   800bcb <strnlen>
  8008cb:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  8008ce:	29 c2                	sub    %eax,%edx
  8008d0:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8008d3:	85 d2                	test   %edx,%edx
  8008d5:	7e d2                	jle    8008a9 <vprintfmt+0x1cc>
					putch(padc, putdat);
  8008d7:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  8008db:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  8008de:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  8008e1:	89 d3                	mov    %edx,%ebx
  8008e3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8008e7:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8008ea:	89 04 24             	mov    %eax,(%esp)
  8008ed:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8008ef:	83 eb 01             	sub    $0x1,%ebx
  8008f2:	85 db                	test   %ebx,%ebx
  8008f4:	7f ed                	jg     8008e3 <vprintfmt+0x206>
  8008f6:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  8008f9:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800900:	eb a7                	jmp    8008a9 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800902:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800906:	74 1a                	je     800922 <vprintfmt+0x245>
  800908:	8d 50 e0             	lea    -0x20(%eax),%edx
  80090b:	83 fa 5e             	cmp    $0x5e,%edx
  80090e:	76 12                	jbe    800922 <vprintfmt+0x245>
					putch('?', putdat);
  800910:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800914:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  80091b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  80091e:	66 90                	xchg   %ax,%ax
  800920:	eb 0a                	jmp    80092c <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  800922:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800926:	89 04 24             	mov    %eax,(%esp)
  800929:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  80092c:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800930:	0f be 03             	movsbl (%ebx),%eax
  800933:	85 c0                	test   %eax,%eax
  800935:	74 05                	je     80093c <vprintfmt+0x25f>
  800937:	83 c3 01             	add    $0x1,%ebx
  80093a:	eb 29                	jmp    800965 <vprintfmt+0x288>
  80093c:	89 fe                	mov    %edi,%esi
  80093e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800941:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800944:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800948:	7f 2e                	jg     800978 <vprintfmt+0x29b>
  80094a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80094d:	e9 b7 fd ff ff       	jmp    800709 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800952:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800955:	83 c2 01             	add    $0x1,%edx
  800958:	89 7d e0             	mov    %edi,-0x20(%ebp)
  80095b:	89 f7                	mov    %esi,%edi
  80095d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800960:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800963:	89 d3                	mov    %edx,%ebx
  800965:	85 f6                	test   %esi,%esi
  800967:	78 99                	js     800902 <vprintfmt+0x225>
  800969:	83 ee 01             	sub    $0x1,%esi
  80096c:	79 94                	jns    800902 <vprintfmt+0x225>
  80096e:	89 fe                	mov    %edi,%esi
  800970:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800973:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800976:	eb cc                	jmp    800944 <vprintfmt+0x267>
  800978:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80097b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80097e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800982:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800989:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80098b:	83 eb 01             	sub    $0x1,%ebx
  80098e:	85 db                	test   %ebx,%ebx
  800990:	7f ec                	jg     80097e <vprintfmt+0x2a1>
  800992:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800995:	e9 6f fd ff ff       	jmp    800709 <vprintfmt+0x2c>
  80099a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80099d:	83 f9 01             	cmp    $0x1,%ecx
  8009a0:	7e 16                	jle    8009b8 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  8009a2:	8b 45 14             	mov    0x14(%ebp),%eax
  8009a5:	8d 50 08             	lea    0x8(%eax),%edx
  8009a8:	89 55 14             	mov    %edx,0x14(%ebp)
  8009ab:	8b 10                	mov    (%eax),%edx
  8009ad:	8b 48 04             	mov    0x4(%eax),%ecx
  8009b0:	89 55 d8             	mov    %edx,-0x28(%ebp)
  8009b3:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8009b6:	eb 32                	jmp    8009ea <vprintfmt+0x30d>
	else if (lflag)
  8009b8:	85 c9                	test   %ecx,%ecx
  8009ba:	74 18                	je     8009d4 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  8009bc:	8b 45 14             	mov    0x14(%ebp),%eax
  8009bf:	8d 50 04             	lea    0x4(%eax),%edx
  8009c2:	89 55 14             	mov    %edx,0x14(%ebp)
  8009c5:	8b 00                	mov    (%eax),%eax
  8009c7:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8009ca:	89 c1                	mov    %eax,%ecx
  8009cc:	c1 f9 1f             	sar    $0x1f,%ecx
  8009cf:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8009d2:	eb 16                	jmp    8009ea <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  8009d4:	8b 45 14             	mov    0x14(%ebp),%eax
  8009d7:	8d 50 04             	lea    0x4(%eax),%edx
  8009da:	89 55 14             	mov    %edx,0x14(%ebp)
  8009dd:	8b 00                	mov    (%eax),%eax
  8009df:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8009e2:	89 c2                	mov    %eax,%edx
  8009e4:	c1 fa 1f             	sar    $0x1f,%edx
  8009e7:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  8009ea:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8009ed:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8009f0:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  8009f5:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  8009f9:	0f 89 9b 00 00 00    	jns    800a9a <vprintfmt+0x3bd>
				putch('-', putdat);
  8009ff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a03:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  800a0a:	ff d7                	call   *%edi
				num = -(long long) num;
  800a0c:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  800a0f:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800a12:	f7 d9                	neg    %ecx
  800a14:	83 d3 00             	adc    $0x0,%ebx
  800a17:	f7 db                	neg    %ebx
  800a19:	b8 0a 00 00 00       	mov    $0xa,%eax
  800a1e:	eb 7a                	jmp    800a9a <vprintfmt+0x3bd>
  800a20:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  800a23:	89 ca                	mov    %ecx,%edx
  800a25:	8d 45 14             	lea    0x14(%ebp),%eax
  800a28:	e8 59 fc ff ff       	call   800686 <getuint>
  800a2d:	89 c1                	mov    %eax,%ecx
  800a2f:	89 d3                	mov    %edx,%ebx
  800a31:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800a36:	eb 62                	jmp    800a9a <vprintfmt+0x3bd>
  800a38:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  800a3b:	89 ca                	mov    %ecx,%edx
  800a3d:	8d 45 14             	lea    0x14(%ebp),%eax
  800a40:	e8 41 fc ff ff       	call   800686 <getuint>
  800a45:	89 c1                	mov    %eax,%ecx
  800a47:	89 d3                	mov    %edx,%ebx
  800a49:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  800a4e:	eb 4a                	jmp    800a9a <vprintfmt+0x3bd>
  800a50:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800a53:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a57:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  800a5e:	ff d7                	call   *%edi
			putch('x', putdat);
  800a60:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a64:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  800a6b:	ff d7                	call   *%edi
			num = (unsigned long long)
  800a6d:	8b 45 14             	mov    0x14(%ebp),%eax
  800a70:	8d 50 04             	lea    0x4(%eax),%edx
  800a73:	89 55 14             	mov    %edx,0x14(%ebp)
  800a76:	8b 08                	mov    (%eax),%ecx
  800a78:	bb 00 00 00 00       	mov    $0x0,%ebx
  800a7d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800a82:	eb 16                	jmp    800a9a <vprintfmt+0x3bd>
  800a84:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800a87:	89 ca                	mov    %ecx,%edx
  800a89:	8d 45 14             	lea    0x14(%ebp),%eax
  800a8c:	e8 f5 fb ff ff       	call   800686 <getuint>
  800a91:	89 c1                	mov    %eax,%ecx
  800a93:	89 d3                	mov    %edx,%ebx
  800a95:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  800a9a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  800a9e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800aa2:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800aa5:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800aa9:	89 44 24 08          	mov    %eax,0x8(%esp)
  800aad:	89 0c 24             	mov    %ecx,(%esp)
  800ab0:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800ab4:	89 f2                	mov    %esi,%edx
  800ab6:	89 f8                	mov    %edi,%eax
  800ab8:	e8 d3 fa ff ff       	call   800590 <printnum>
  800abd:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800ac0:	e9 44 fc ff ff       	jmp    800709 <vprintfmt+0x2c>
  800ac5:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800ac8:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  800acb:	89 74 24 04          	mov    %esi,0x4(%esp)
  800acf:	89 14 24             	mov    %edx,(%esp)
  800ad2:	ff d7                	call   *%edi
  800ad4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800ad7:	e9 2d fc ff ff       	jmp    800709 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  800adc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ae0:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800ae7:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800ae9:	8d 43 ff             	lea    -0x1(%ebx),%eax
  800aec:	80 38 25             	cmpb   $0x25,(%eax)
  800aef:	0f 84 14 fc ff ff    	je     800709 <vprintfmt+0x2c>
  800af5:	89 c3                	mov    %eax,%ebx
  800af7:	eb f0                	jmp    800ae9 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800af9:	83 c4 5c             	add    $0x5c,%esp
  800afc:	5b                   	pop    %ebx
  800afd:	5e                   	pop    %esi
  800afe:	5f                   	pop    %edi
  800aff:	5d                   	pop    %ebp
  800b00:	c3                   	ret    

00800b01 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800b01:	55                   	push   %ebp
  800b02:	89 e5                	mov    %esp,%ebp
  800b04:	83 ec 28             	sub    $0x28,%esp
  800b07:	8b 45 08             	mov    0x8(%ebp),%eax
  800b0a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  800b0d:	85 c0                	test   %eax,%eax
  800b0f:	74 04                	je     800b15 <vsnprintf+0x14>
  800b11:	85 d2                	test   %edx,%edx
  800b13:	7f 07                	jg     800b1c <vsnprintf+0x1b>
  800b15:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800b1a:	eb 3b                	jmp    800b57 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  800b1c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  800b1f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  800b23:	89 45 f0             	mov    %eax,-0x10(%ebp)
  800b26:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  800b2d:	8b 45 14             	mov    0x14(%ebp),%eax
  800b30:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b34:	8b 45 10             	mov    0x10(%ebp),%eax
  800b37:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b3b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800b3e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b42:	c7 04 24 c0 06 80 00 	movl   $0x8006c0,(%esp)
  800b49:	e8 8f fb ff ff       	call   8006dd <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800b4e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800b51:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800b54:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800b57:	c9                   	leave  
  800b58:	c3                   	ret    

00800b59 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800b59:	55                   	push   %ebp
  800b5a:	89 e5                	mov    %esp,%ebp
  800b5c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  800b5f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800b62:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b66:	8b 45 10             	mov    0x10(%ebp),%eax
  800b69:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b6d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b70:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b74:	8b 45 08             	mov    0x8(%ebp),%eax
  800b77:	89 04 24             	mov    %eax,(%esp)
  800b7a:	e8 82 ff ff ff       	call   800b01 <vsnprintf>
	va_end(ap);

	return rc;
}
  800b7f:	c9                   	leave  
  800b80:	c3                   	ret    

00800b81 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800b81:	55                   	push   %ebp
  800b82:	89 e5                	mov    %esp,%ebp
  800b84:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800b87:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  800b8a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b8e:	8b 45 10             	mov    0x10(%ebp),%eax
  800b91:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b95:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b98:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b9c:	8b 45 08             	mov    0x8(%ebp),%eax
  800b9f:	89 04 24             	mov    %eax,(%esp)
  800ba2:	e8 36 fb ff ff       	call   8006dd <vprintfmt>
	va_end(ap);
}
  800ba7:	c9                   	leave  
  800ba8:	c3                   	ret    
  800ba9:	00 00                	add    %al,(%eax)
  800bab:	00 00                	add    %al,(%eax)
  800bad:	00 00                	add    %al,(%eax)
	...

00800bb0 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800bb0:	55                   	push   %ebp
  800bb1:	89 e5                	mov    %esp,%ebp
  800bb3:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800bb6:	b8 00 00 00 00       	mov    $0x0,%eax
  800bbb:	80 3a 00             	cmpb   $0x0,(%edx)
  800bbe:	74 09                	je     800bc9 <strlen+0x19>
		n++;
  800bc0:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800bc3:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800bc7:	75 f7                	jne    800bc0 <strlen+0x10>
		n++;
	return n;
}
  800bc9:	5d                   	pop    %ebp
  800bca:	c3                   	ret    

00800bcb <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800bcb:	55                   	push   %ebp
  800bcc:	89 e5                	mov    %esp,%ebp
  800bce:	53                   	push   %ebx
  800bcf:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800bd2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800bd5:	85 c9                	test   %ecx,%ecx
  800bd7:	74 19                	je     800bf2 <strnlen+0x27>
  800bd9:	80 3b 00             	cmpb   $0x0,(%ebx)
  800bdc:	74 14                	je     800bf2 <strnlen+0x27>
  800bde:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800be3:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800be6:	39 c8                	cmp    %ecx,%eax
  800be8:	74 0d                	je     800bf7 <strnlen+0x2c>
  800bea:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  800bee:	75 f3                	jne    800be3 <strnlen+0x18>
  800bf0:	eb 05                	jmp    800bf7 <strnlen+0x2c>
  800bf2:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800bf7:	5b                   	pop    %ebx
  800bf8:	5d                   	pop    %ebp
  800bf9:	c3                   	ret    

00800bfa <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800bfa:	55                   	push   %ebp
  800bfb:	89 e5                	mov    %esp,%ebp
  800bfd:	53                   	push   %ebx
  800bfe:	8b 45 08             	mov    0x8(%ebp),%eax
  800c01:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800c04:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800c09:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  800c0d:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800c10:	83 c2 01             	add    $0x1,%edx
  800c13:	84 c9                	test   %cl,%cl
  800c15:	75 f2                	jne    800c09 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800c17:	5b                   	pop    %ebx
  800c18:	5d                   	pop    %ebp
  800c19:	c3                   	ret    

00800c1a <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800c1a:	55                   	push   %ebp
  800c1b:	89 e5                	mov    %esp,%ebp
  800c1d:	56                   	push   %esi
  800c1e:	53                   	push   %ebx
  800c1f:	8b 45 08             	mov    0x8(%ebp),%eax
  800c22:	8b 55 0c             	mov    0xc(%ebp),%edx
  800c25:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800c28:	85 f6                	test   %esi,%esi
  800c2a:	74 18                	je     800c44 <strncpy+0x2a>
  800c2c:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800c31:	0f b6 1a             	movzbl (%edx),%ebx
  800c34:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800c37:	80 3a 01             	cmpb   $0x1,(%edx)
  800c3a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800c3d:	83 c1 01             	add    $0x1,%ecx
  800c40:	39 ce                	cmp    %ecx,%esi
  800c42:	77 ed                	ja     800c31 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800c44:	5b                   	pop    %ebx
  800c45:	5e                   	pop    %esi
  800c46:	5d                   	pop    %ebp
  800c47:	c3                   	ret    

00800c48 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800c48:	55                   	push   %ebp
  800c49:	89 e5                	mov    %esp,%ebp
  800c4b:	56                   	push   %esi
  800c4c:	53                   	push   %ebx
  800c4d:	8b 75 08             	mov    0x8(%ebp),%esi
  800c50:	8b 55 0c             	mov    0xc(%ebp),%edx
  800c53:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800c56:	89 f0                	mov    %esi,%eax
  800c58:	85 c9                	test   %ecx,%ecx
  800c5a:	74 27                	je     800c83 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800c5c:	83 e9 01             	sub    $0x1,%ecx
  800c5f:	74 1d                	je     800c7e <strlcpy+0x36>
  800c61:	0f b6 1a             	movzbl (%edx),%ebx
  800c64:	84 db                	test   %bl,%bl
  800c66:	74 16                	je     800c7e <strlcpy+0x36>
			*dst++ = *src++;
  800c68:	88 18                	mov    %bl,(%eax)
  800c6a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800c6d:	83 e9 01             	sub    $0x1,%ecx
  800c70:	74 0e                	je     800c80 <strlcpy+0x38>
			*dst++ = *src++;
  800c72:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800c75:	0f b6 1a             	movzbl (%edx),%ebx
  800c78:	84 db                	test   %bl,%bl
  800c7a:	75 ec                	jne    800c68 <strlcpy+0x20>
  800c7c:	eb 02                	jmp    800c80 <strlcpy+0x38>
  800c7e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800c80:	c6 00 00             	movb   $0x0,(%eax)
  800c83:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800c85:	5b                   	pop    %ebx
  800c86:	5e                   	pop    %esi
  800c87:	5d                   	pop    %ebp
  800c88:	c3                   	ret    

00800c89 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800c89:	55                   	push   %ebp
  800c8a:	89 e5                	mov    %esp,%ebp
  800c8c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800c8f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800c92:	0f b6 01             	movzbl (%ecx),%eax
  800c95:	84 c0                	test   %al,%al
  800c97:	74 15                	je     800cae <strcmp+0x25>
  800c99:	3a 02                	cmp    (%edx),%al
  800c9b:	75 11                	jne    800cae <strcmp+0x25>
		p++, q++;
  800c9d:	83 c1 01             	add    $0x1,%ecx
  800ca0:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800ca3:	0f b6 01             	movzbl (%ecx),%eax
  800ca6:	84 c0                	test   %al,%al
  800ca8:	74 04                	je     800cae <strcmp+0x25>
  800caa:	3a 02                	cmp    (%edx),%al
  800cac:	74 ef                	je     800c9d <strcmp+0x14>
  800cae:	0f b6 c0             	movzbl %al,%eax
  800cb1:	0f b6 12             	movzbl (%edx),%edx
  800cb4:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800cb6:	5d                   	pop    %ebp
  800cb7:	c3                   	ret    

00800cb8 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800cb8:	55                   	push   %ebp
  800cb9:	89 e5                	mov    %esp,%ebp
  800cbb:	53                   	push   %ebx
  800cbc:	8b 55 08             	mov    0x8(%ebp),%edx
  800cbf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800cc2:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800cc5:	85 c0                	test   %eax,%eax
  800cc7:	74 23                	je     800cec <strncmp+0x34>
  800cc9:	0f b6 1a             	movzbl (%edx),%ebx
  800ccc:	84 db                	test   %bl,%bl
  800cce:	74 24                	je     800cf4 <strncmp+0x3c>
  800cd0:	3a 19                	cmp    (%ecx),%bl
  800cd2:	75 20                	jne    800cf4 <strncmp+0x3c>
  800cd4:	83 e8 01             	sub    $0x1,%eax
  800cd7:	74 13                	je     800cec <strncmp+0x34>
		n--, p++, q++;
  800cd9:	83 c2 01             	add    $0x1,%edx
  800cdc:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800cdf:	0f b6 1a             	movzbl (%edx),%ebx
  800ce2:	84 db                	test   %bl,%bl
  800ce4:	74 0e                	je     800cf4 <strncmp+0x3c>
  800ce6:	3a 19                	cmp    (%ecx),%bl
  800ce8:	74 ea                	je     800cd4 <strncmp+0x1c>
  800cea:	eb 08                	jmp    800cf4 <strncmp+0x3c>
  800cec:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800cf1:	5b                   	pop    %ebx
  800cf2:	5d                   	pop    %ebp
  800cf3:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800cf4:	0f b6 02             	movzbl (%edx),%eax
  800cf7:	0f b6 11             	movzbl (%ecx),%edx
  800cfa:	29 d0                	sub    %edx,%eax
  800cfc:	eb f3                	jmp    800cf1 <strncmp+0x39>

00800cfe <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800cfe:	55                   	push   %ebp
  800cff:	89 e5                	mov    %esp,%ebp
  800d01:	8b 45 08             	mov    0x8(%ebp),%eax
  800d04:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800d08:	0f b6 10             	movzbl (%eax),%edx
  800d0b:	84 d2                	test   %dl,%dl
  800d0d:	74 15                	je     800d24 <strchr+0x26>
		if (*s == c)
  800d0f:	38 ca                	cmp    %cl,%dl
  800d11:	75 07                	jne    800d1a <strchr+0x1c>
  800d13:	eb 14                	jmp    800d29 <strchr+0x2b>
  800d15:	38 ca                	cmp    %cl,%dl
  800d17:	90                   	nop
  800d18:	74 0f                	je     800d29 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800d1a:	83 c0 01             	add    $0x1,%eax
  800d1d:	0f b6 10             	movzbl (%eax),%edx
  800d20:	84 d2                	test   %dl,%dl
  800d22:	75 f1                	jne    800d15 <strchr+0x17>
  800d24:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800d29:	5d                   	pop    %ebp
  800d2a:	c3                   	ret    

00800d2b <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800d2b:	55                   	push   %ebp
  800d2c:	89 e5                	mov    %esp,%ebp
  800d2e:	8b 45 08             	mov    0x8(%ebp),%eax
  800d31:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800d35:	0f b6 10             	movzbl (%eax),%edx
  800d38:	84 d2                	test   %dl,%dl
  800d3a:	74 18                	je     800d54 <strfind+0x29>
		if (*s == c)
  800d3c:	38 ca                	cmp    %cl,%dl
  800d3e:	75 0a                	jne    800d4a <strfind+0x1f>
  800d40:	eb 12                	jmp    800d54 <strfind+0x29>
  800d42:	38 ca                	cmp    %cl,%dl
  800d44:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800d48:	74 0a                	je     800d54 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800d4a:	83 c0 01             	add    $0x1,%eax
  800d4d:	0f b6 10             	movzbl (%eax),%edx
  800d50:	84 d2                	test   %dl,%dl
  800d52:	75 ee                	jne    800d42 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800d54:	5d                   	pop    %ebp
  800d55:	c3                   	ret    

00800d56 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800d56:	55                   	push   %ebp
  800d57:	89 e5                	mov    %esp,%ebp
  800d59:	83 ec 0c             	sub    $0xc,%esp
  800d5c:	89 1c 24             	mov    %ebx,(%esp)
  800d5f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d63:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800d67:	8b 7d 08             	mov    0x8(%ebp),%edi
  800d6a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d6d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800d70:	85 c9                	test   %ecx,%ecx
  800d72:	74 30                	je     800da4 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800d74:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800d7a:	75 25                	jne    800da1 <memset+0x4b>
  800d7c:	f6 c1 03             	test   $0x3,%cl
  800d7f:	75 20                	jne    800da1 <memset+0x4b>
		c &= 0xFF;
  800d81:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800d84:	89 d3                	mov    %edx,%ebx
  800d86:	c1 e3 08             	shl    $0x8,%ebx
  800d89:	89 d6                	mov    %edx,%esi
  800d8b:	c1 e6 18             	shl    $0x18,%esi
  800d8e:	89 d0                	mov    %edx,%eax
  800d90:	c1 e0 10             	shl    $0x10,%eax
  800d93:	09 f0                	or     %esi,%eax
  800d95:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800d97:	09 d8                	or     %ebx,%eax
  800d99:	c1 e9 02             	shr    $0x2,%ecx
  800d9c:	fc                   	cld    
  800d9d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800d9f:	eb 03                	jmp    800da4 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800da1:	fc                   	cld    
  800da2:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800da4:	89 f8                	mov    %edi,%eax
  800da6:	8b 1c 24             	mov    (%esp),%ebx
  800da9:	8b 74 24 04          	mov    0x4(%esp),%esi
  800dad:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800db1:	89 ec                	mov    %ebp,%esp
  800db3:	5d                   	pop    %ebp
  800db4:	c3                   	ret    

00800db5 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800db5:	55                   	push   %ebp
  800db6:	89 e5                	mov    %esp,%ebp
  800db8:	83 ec 08             	sub    $0x8,%esp
  800dbb:	89 34 24             	mov    %esi,(%esp)
  800dbe:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800dc2:	8b 45 08             	mov    0x8(%ebp),%eax
  800dc5:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800dc8:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800dcb:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800dcd:	39 c6                	cmp    %eax,%esi
  800dcf:	73 35                	jae    800e06 <memmove+0x51>
  800dd1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800dd4:	39 d0                	cmp    %edx,%eax
  800dd6:	73 2e                	jae    800e06 <memmove+0x51>
		s += n;
		d += n;
  800dd8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800dda:	f6 c2 03             	test   $0x3,%dl
  800ddd:	75 1b                	jne    800dfa <memmove+0x45>
  800ddf:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800de5:	75 13                	jne    800dfa <memmove+0x45>
  800de7:	f6 c1 03             	test   $0x3,%cl
  800dea:	75 0e                	jne    800dfa <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800dec:	83 ef 04             	sub    $0x4,%edi
  800def:	8d 72 fc             	lea    -0x4(%edx),%esi
  800df2:	c1 e9 02             	shr    $0x2,%ecx
  800df5:	fd                   	std    
  800df6:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800df8:	eb 09                	jmp    800e03 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800dfa:	83 ef 01             	sub    $0x1,%edi
  800dfd:	8d 72 ff             	lea    -0x1(%edx),%esi
  800e00:	fd                   	std    
  800e01:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800e03:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800e04:	eb 20                	jmp    800e26 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800e06:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800e0c:	75 15                	jne    800e23 <memmove+0x6e>
  800e0e:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800e14:	75 0d                	jne    800e23 <memmove+0x6e>
  800e16:	f6 c1 03             	test   $0x3,%cl
  800e19:	75 08                	jne    800e23 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800e1b:	c1 e9 02             	shr    $0x2,%ecx
  800e1e:	fc                   	cld    
  800e1f:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800e21:	eb 03                	jmp    800e26 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800e23:	fc                   	cld    
  800e24:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800e26:	8b 34 24             	mov    (%esp),%esi
  800e29:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800e2d:	89 ec                	mov    %ebp,%esp
  800e2f:	5d                   	pop    %ebp
  800e30:	c3                   	ret    

00800e31 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800e31:	55                   	push   %ebp
  800e32:	89 e5                	mov    %esp,%ebp
  800e34:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800e37:	8b 45 10             	mov    0x10(%ebp),%eax
  800e3a:	89 44 24 08          	mov    %eax,0x8(%esp)
  800e3e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800e41:	89 44 24 04          	mov    %eax,0x4(%esp)
  800e45:	8b 45 08             	mov    0x8(%ebp),%eax
  800e48:	89 04 24             	mov    %eax,(%esp)
  800e4b:	e8 65 ff ff ff       	call   800db5 <memmove>
}
  800e50:	c9                   	leave  
  800e51:	c3                   	ret    

00800e52 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800e52:	55                   	push   %ebp
  800e53:	89 e5                	mov    %esp,%ebp
  800e55:	57                   	push   %edi
  800e56:	56                   	push   %esi
  800e57:	53                   	push   %ebx
  800e58:	8b 75 08             	mov    0x8(%ebp),%esi
  800e5b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800e5e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800e61:	85 c9                	test   %ecx,%ecx
  800e63:	74 36                	je     800e9b <memcmp+0x49>
		if (*s1 != *s2)
  800e65:	0f b6 06             	movzbl (%esi),%eax
  800e68:	0f b6 1f             	movzbl (%edi),%ebx
  800e6b:	38 d8                	cmp    %bl,%al
  800e6d:	74 20                	je     800e8f <memcmp+0x3d>
  800e6f:	eb 14                	jmp    800e85 <memcmp+0x33>
  800e71:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800e76:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800e7b:	83 c2 01             	add    $0x1,%edx
  800e7e:	83 e9 01             	sub    $0x1,%ecx
  800e81:	38 d8                	cmp    %bl,%al
  800e83:	74 12                	je     800e97 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800e85:	0f b6 c0             	movzbl %al,%eax
  800e88:	0f b6 db             	movzbl %bl,%ebx
  800e8b:	29 d8                	sub    %ebx,%eax
  800e8d:	eb 11                	jmp    800ea0 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800e8f:	83 e9 01             	sub    $0x1,%ecx
  800e92:	ba 00 00 00 00       	mov    $0x0,%edx
  800e97:	85 c9                	test   %ecx,%ecx
  800e99:	75 d6                	jne    800e71 <memcmp+0x1f>
  800e9b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800ea0:	5b                   	pop    %ebx
  800ea1:	5e                   	pop    %esi
  800ea2:	5f                   	pop    %edi
  800ea3:	5d                   	pop    %ebp
  800ea4:	c3                   	ret    

00800ea5 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800ea5:	55                   	push   %ebp
  800ea6:	89 e5                	mov    %esp,%ebp
  800ea8:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800eab:	89 c2                	mov    %eax,%edx
  800ead:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800eb0:	39 d0                	cmp    %edx,%eax
  800eb2:	73 15                	jae    800ec9 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800eb4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800eb8:	38 08                	cmp    %cl,(%eax)
  800eba:	75 06                	jne    800ec2 <memfind+0x1d>
  800ebc:	eb 0b                	jmp    800ec9 <memfind+0x24>
  800ebe:	38 08                	cmp    %cl,(%eax)
  800ec0:	74 07                	je     800ec9 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800ec2:	83 c0 01             	add    $0x1,%eax
  800ec5:	39 c2                	cmp    %eax,%edx
  800ec7:	77 f5                	ja     800ebe <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800ec9:	5d                   	pop    %ebp
  800eca:	c3                   	ret    

00800ecb <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800ecb:	55                   	push   %ebp
  800ecc:	89 e5                	mov    %esp,%ebp
  800ece:	57                   	push   %edi
  800ecf:	56                   	push   %esi
  800ed0:	53                   	push   %ebx
  800ed1:	83 ec 04             	sub    $0x4,%esp
  800ed4:	8b 55 08             	mov    0x8(%ebp),%edx
  800ed7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800eda:	0f b6 02             	movzbl (%edx),%eax
  800edd:	3c 20                	cmp    $0x20,%al
  800edf:	74 04                	je     800ee5 <strtol+0x1a>
  800ee1:	3c 09                	cmp    $0x9,%al
  800ee3:	75 0e                	jne    800ef3 <strtol+0x28>
		s++;
  800ee5:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800ee8:	0f b6 02             	movzbl (%edx),%eax
  800eeb:	3c 20                	cmp    $0x20,%al
  800eed:	74 f6                	je     800ee5 <strtol+0x1a>
  800eef:	3c 09                	cmp    $0x9,%al
  800ef1:	74 f2                	je     800ee5 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800ef3:	3c 2b                	cmp    $0x2b,%al
  800ef5:	75 0c                	jne    800f03 <strtol+0x38>
		s++;
  800ef7:	83 c2 01             	add    $0x1,%edx
  800efa:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800f01:	eb 15                	jmp    800f18 <strtol+0x4d>
	else if (*s == '-')
  800f03:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800f0a:	3c 2d                	cmp    $0x2d,%al
  800f0c:	75 0a                	jne    800f18 <strtol+0x4d>
		s++, neg = 1;
  800f0e:	83 c2 01             	add    $0x1,%edx
  800f11:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800f18:	85 db                	test   %ebx,%ebx
  800f1a:	0f 94 c0             	sete   %al
  800f1d:	74 05                	je     800f24 <strtol+0x59>
  800f1f:	83 fb 10             	cmp    $0x10,%ebx
  800f22:	75 18                	jne    800f3c <strtol+0x71>
  800f24:	80 3a 30             	cmpb   $0x30,(%edx)
  800f27:	75 13                	jne    800f3c <strtol+0x71>
  800f29:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800f2d:	8d 76 00             	lea    0x0(%esi),%esi
  800f30:	75 0a                	jne    800f3c <strtol+0x71>
		s += 2, base = 16;
  800f32:	83 c2 02             	add    $0x2,%edx
  800f35:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800f3a:	eb 15                	jmp    800f51 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800f3c:	84 c0                	test   %al,%al
  800f3e:	66 90                	xchg   %ax,%ax
  800f40:	74 0f                	je     800f51 <strtol+0x86>
  800f42:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800f47:	80 3a 30             	cmpb   $0x30,(%edx)
  800f4a:	75 05                	jne    800f51 <strtol+0x86>
		s++, base = 8;
  800f4c:	83 c2 01             	add    $0x1,%edx
  800f4f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800f51:	b8 00 00 00 00       	mov    $0x0,%eax
  800f56:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800f58:	0f b6 0a             	movzbl (%edx),%ecx
  800f5b:	89 cf                	mov    %ecx,%edi
  800f5d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800f60:	80 fb 09             	cmp    $0x9,%bl
  800f63:	77 08                	ja     800f6d <strtol+0xa2>
			dig = *s - '0';
  800f65:	0f be c9             	movsbl %cl,%ecx
  800f68:	83 e9 30             	sub    $0x30,%ecx
  800f6b:	eb 1e                	jmp    800f8b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800f6d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800f70:	80 fb 19             	cmp    $0x19,%bl
  800f73:	77 08                	ja     800f7d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800f75:	0f be c9             	movsbl %cl,%ecx
  800f78:	83 e9 57             	sub    $0x57,%ecx
  800f7b:	eb 0e                	jmp    800f8b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800f7d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800f80:	80 fb 19             	cmp    $0x19,%bl
  800f83:	77 15                	ja     800f9a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800f85:	0f be c9             	movsbl %cl,%ecx
  800f88:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800f8b:	39 f1                	cmp    %esi,%ecx
  800f8d:	7d 0b                	jge    800f9a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800f8f:	83 c2 01             	add    $0x1,%edx
  800f92:	0f af c6             	imul   %esi,%eax
  800f95:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800f98:	eb be                	jmp    800f58 <strtol+0x8d>
  800f9a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800f9c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800fa0:	74 05                	je     800fa7 <strtol+0xdc>
		*endptr = (char *) s;
  800fa2:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800fa5:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800fa7:	89 ca                	mov    %ecx,%edx
  800fa9:	f7 da                	neg    %edx
  800fab:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800faf:	0f 45 c2             	cmovne %edx,%eax
}
  800fb2:	83 c4 04             	add    $0x4,%esp
  800fb5:	5b                   	pop    %ebx
  800fb6:	5e                   	pop    %esi
  800fb7:	5f                   	pop    %edi
  800fb8:	5d                   	pop    %ebp
  800fb9:	c3                   	ret    
	...

00800fbc <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800fbc:	55                   	push   %ebp
  800fbd:	89 e5                	mov    %esp,%ebp
  800fbf:	83 ec 0c             	sub    $0xc,%esp
  800fc2:	89 1c 24             	mov    %ebx,(%esp)
  800fc5:	89 74 24 04          	mov    %esi,0x4(%esp)
  800fc9:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fcd:	ba 00 00 00 00       	mov    $0x0,%edx
  800fd2:	b8 01 00 00 00       	mov    $0x1,%eax
  800fd7:	89 d1                	mov    %edx,%ecx
  800fd9:	89 d3                	mov    %edx,%ebx
  800fdb:	89 d7                	mov    %edx,%edi
  800fdd:	89 d6                	mov    %edx,%esi
  800fdf:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800fe1:	8b 1c 24             	mov    (%esp),%ebx
  800fe4:	8b 74 24 04          	mov    0x4(%esp),%esi
  800fe8:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800fec:	89 ec                	mov    %ebp,%esp
  800fee:	5d                   	pop    %ebp
  800fef:	c3                   	ret    

00800ff0 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800ff0:	55                   	push   %ebp
  800ff1:	89 e5                	mov    %esp,%ebp
  800ff3:	83 ec 0c             	sub    $0xc,%esp
  800ff6:	89 1c 24             	mov    %ebx,(%esp)
  800ff9:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ffd:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801001:	b8 00 00 00 00       	mov    $0x0,%eax
  801006:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801009:	8b 55 08             	mov    0x8(%ebp),%edx
  80100c:	89 c3                	mov    %eax,%ebx
  80100e:	89 c7                	mov    %eax,%edi
  801010:	89 c6                	mov    %eax,%esi
  801012:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  801014:	8b 1c 24             	mov    (%esp),%ebx
  801017:	8b 74 24 04          	mov    0x4(%esp),%esi
  80101b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80101f:	89 ec                	mov    %ebp,%esp
  801021:	5d                   	pop    %ebp
  801022:	c3                   	ret    

00801023 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  801023:	55                   	push   %ebp
  801024:	89 e5                	mov    %esp,%ebp
  801026:	83 ec 0c             	sub    $0xc,%esp
  801029:	89 1c 24             	mov    %ebx,(%esp)
  80102c:	89 74 24 04          	mov    %esi,0x4(%esp)
  801030:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801034:	bb 00 00 00 00       	mov    $0x0,%ebx
  801039:	b8 10 00 00 00       	mov    $0x10,%eax
  80103e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801041:	8b 55 08             	mov    0x8(%ebp),%edx
  801044:	89 df                	mov    %ebx,%edi
  801046:	89 de                	mov    %ebx,%esi
  801048:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  80104a:	8b 1c 24             	mov    (%esp),%ebx
  80104d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801051:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801055:	89 ec                	mov    %ebp,%esp
  801057:	5d                   	pop    %ebp
  801058:	c3                   	ret    

00801059 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  801059:	55                   	push   %ebp
  80105a:	89 e5                	mov    %esp,%ebp
  80105c:	83 ec 0c             	sub    $0xc,%esp
  80105f:	89 1c 24             	mov    %ebx,(%esp)
  801062:	89 74 24 04          	mov    %esi,0x4(%esp)
  801066:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80106a:	bb 00 00 00 00       	mov    $0x0,%ebx
  80106f:	b8 0f 00 00 00       	mov    $0xf,%eax
  801074:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801077:	8b 55 08             	mov    0x8(%ebp),%edx
  80107a:	89 df                	mov    %ebx,%edi
  80107c:	89 de                	mov    %ebx,%esi
  80107e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  801080:	8b 1c 24             	mov    (%esp),%ebx
  801083:	8b 74 24 04          	mov    0x4(%esp),%esi
  801087:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80108b:	89 ec                	mov    %ebp,%esp
  80108d:	5d                   	pop    %ebp
  80108e:	c3                   	ret    

0080108f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  80108f:	55                   	push   %ebp
  801090:	89 e5                	mov    %esp,%ebp
  801092:	83 ec 0c             	sub    $0xc,%esp
  801095:	89 1c 24             	mov    %ebx,(%esp)
  801098:	89 74 24 04          	mov    %esi,0x4(%esp)
  80109c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010a0:	ba 00 00 00 00       	mov    $0x0,%edx
  8010a5:	b8 0e 00 00 00       	mov    $0xe,%eax
  8010aa:	89 d1                	mov    %edx,%ecx
  8010ac:	89 d3                	mov    %edx,%ebx
  8010ae:	89 d7                	mov    %edx,%edi
  8010b0:	89 d6                	mov    %edx,%esi
  8010b2:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  8010b4:	8b 1c 24             	mov    (%esp),%ebx
  8010b7:	8b 74 24 04          	mov    0x4(%esp),%esi
  8010bb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8010bf:	89 ec                	mov    %ebp,%esp
  8010c1:	5d                   	pop    %ebp
  8010c2:	c3                   	ret    

008010c3 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  8010c3:	55                   	push   %ebp
  8010c4:	89 e5                	mov    %esp,%ebp
  8010c6:	83 ec 38             	sub    $0x38,%esp
  8010c9:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010cc:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010cf:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010d2:	b9 00 00 00 00       	mov    $0x0,%ecx
  8010d7:	b8 0d 00 00 00       	mov    $0xd,%eax
  8010dc:	8b 55 08             	mov    0x8(%ebp),%edx
  8010df:	89 cb                	mov    %ecx,%ebx
  8010e1:	89 cf                	mov    %ecx,%edi
  8010e3:	89 ce                	mov    %ecx,%esi
  8010e5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010e7:	85 c0                	test   %eax,%eax
  8010e9:	7e 28                	jle    801113 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010eb:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010ef:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  8010f6:	00 
  8010f7:	c7 44 24 08 eb 35 80 	movl   $0x8035eb,0x8(%esp)
  8010fe:	00 
  8010ff:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801106:	00 
  801107:	c7 04 24 08 36 80 00 	movl   $0x803608,(%esp)
  80110e:	e8 59 f3 ff ff       	call   80046c <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  801113:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801116:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801119:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80111c:	89 ec                	mov    %ebp,%esp
  80111e:	5d                   	pop    %ebp
  80111f:	c3                   	ret    

00801120 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  801120:	55                   	push   %ebp
  801121:	89 e5                	mov    %esp,%ebp
  801123:	83 ec 38             	sub    $0x38,%esp
  801126:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801129:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80112c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80112f:	be 00 00 00 00       	mov    $0x0,%esi
  801134:	b8 0c 00 00 00       	mov    $0xc,%eax
  801139:	8b 7d 14             	mov    0x14(%ebp),%edi
  80113c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80113f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801142:	8b 55 08             	mov    0x8(%ebp),%edx
  801145:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801147:	85 c0                	test   %eax,%eax
  801149:	7e 28                	jle    801173 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  80114b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80114f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  801156:	00 
  801157:	c7 44 24 08 eb 35 80 	movl   $0x8035eb,0x8(%esp)
  80115e:	00 
  80115f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801166:	00 
  801167:	c7 04 24 08 36 80 00 	movl   $0x803608,(%esp)
  80116e:	e8 f9 f2 ff ff       	call   80046c <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  801173:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801176:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801179:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80117c:	89 ec                	mov    %ebp,%esp
  80117e:	5d                   	pop    %ebp
  80117f:	c3                   	ret    

00801180 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  801180:	55                   	push   %ebp
  801181:	89 e5                	mov    %esp,%ebp
  801183:	83 ec 38             	sub    $0x38,%esp
  801186:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801189:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80118c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80118f:	bb 00 00 00 00       	mov    $0x0,%ebx
  801194:	b8 0a 00 00 00       	mov    $0xa,%eax
  801199:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80119c:	8b 55 08             	mov    0x8(%ebp),%edx
  80119f:	89 df                	mov    %ebx,%edi
  8011a1:	89 de                	mov    %ebx,%esi
  8011a3:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8011a5:	85 c0                	test   %eax,%eax
  8011a7:	7e 28                	jle    8011d1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011a9:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011ad:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  8011b4:	00 
  8011b5:	c7 44 24 08 eb 35 80 	movl   $0x8035eb,0x8(%esp)
  8011bc:	00 
  8011bd:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011c4:	00 
  8011c5:	c7 04 24 08 36 80 00 	movl   $0x803608,(%esp)
  8011cc:	e8 9b f2 ff ff       	call   80046c <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  8011d1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8011d4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8011d7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8011da:	89 ec                	mov    %ebp,%esp
  8011dc:	5d                   	pop    %ebp
  8011dd:	c3                   	ret    

008011de <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  8011de:	55                   	push   %ebp
  8011df:	89 e5                	mov    %esp,%ebp
  8011e1:	83 ec 38             	sub    $0x38,%esp
  8011e4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011e7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011ea:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011ed:	bb 00 00 00 00       	mov    $0x0,%ebx
  8011f2:	b8 09 00 00 00       	mov    $0x9,%eax
  8011f7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8011fa:	8b 55 08             	mov    0x8(%ebp),%edx
  8011fd:	89 df                	mov    %ebx,%edi
  8011ff:	89 de                	mov    %ebx,%esi
  801201:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801203:	85 c0                	test   %eax,%eax
  801205:	7e 28                	jle    80122f <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801207:	89 44 24 10          	mov    %eax,0x10(%esp)
  80120b:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  801212:	00 
  801213:	c7 44 24 08 eb 35 80 	movl   $0x8035eb,0x8(%esp)
  80121a:	00 
  80121b:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801222:	00 
  801223:	c7 04 24 08 36 80 00 	movl   $0x803608,(%esp)
  80122a:	e8 3d f2 ff ff       	call   80046c <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  80122f:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801232:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801235:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801238:	89 ec                	mov    %ebp,%esp
  80123a:	5d                   	pop    %ebp
  80123b:	c3                   	ret    

0080123c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80123c:	55                   	push   %ebp
  80123d:	89 e5                	mov    %esp,%ebp
  80123f:	83 ec 38             	sub    $0x38,%esp
  801242:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801245:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801248:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80124b:	bb 00 00 00 00       	mov    $0x0,%ebx
  801250:	b8 08 00 00 00       	mov    $0x8,%eax
  801255:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801258:	8b 55 08             	mov    0x8(%ebp),%edx
  80125b:	89 df                	mov    %ebx,%edi
  80125d:	89 de                	mov    %ebx,%esi
  80125f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801261:	85 c0                	test   %eax,%eax
  801263:	7e 28                	jle    80128d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801265:	89 44 24 10          	mov    %eax,0x10(%esp)
  801269:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801270:	00 
  801271:	c7 44 24 08 eb 35 80 	movl   $0x8035eb,0x8(%esp)
  801278:	00 
  801279:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801280:	00 
  801281:	c7 04 24 08 36 80 00 	movl   $0x803608,(%esp)
  801288:	e8 df f1 ff ff       	call   80046c <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80128d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801290:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801293:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801296:	89 ec                	mov    %ebp,%esp
  801298:	5d                   	pop    %ebp
  801299:	c3                   	ret    

0080129a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80129a:	55                   	push   %ebp
  80129b:	89 e5                	mov    %esp,%ebp
  80129d:	83 ec 38             	sub    $0x38,%esp
  8012a0:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8012a3:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8012a6:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012a9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8012ae:	b8 06 00 00 00       	mov    $0x6,%eax
  8012b3:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8012b6:	8b 55 08             	mov    0x8(%ebp),%edx
  8012b9:	89 df                	mov    %ebx,%edi
  8012bb:	89 de                	mov    %ebx,%esi
  8012bd:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8012bf:	85 c0                	test   %eax,%eax
  8012c1:	7e 28                	jle    8012eb <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8012c3:	89 44 24 10          	mov    %eax,0x10(%esp)
  8012c7:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  8012ce:	00 
  8012cf:	c7 44 24 08 eb 35 80 	movl   $0x8035eb,0x8(%esp)
  8012d6:	00 
  8012d7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8012de:	00 
  8012df:	c7 04 24 08 36 80 00 	movl   $0x803608,(%esp)
  8012e6:	e8 81 f1 ff ff       	call   80046c <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  8012eb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8012ee:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8012f1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8012f4:	89 ec                	mov    %ebp,%esp
  8012f6:	5d                   	pop    %ebp
  8012f7:	c3                   	ret    

008012f8 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  8012f8:	55                   	push   %ebp
  8012f9:	89 e5                	mov    %esp,%ebp
  8012fb:	83 ec 38             	sub    $0x38,%esp
  8012fe:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801301:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801304:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801307:	b8 05 00 00 00       	mov    $0x5,%eax
  80130c:	8b 75 18             	mov    0x18(%ebp),%esi
  80130f:	8b 7d 14             	mov    0x14(%ebp),%edi
  801312:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801315:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801318:	8b 55 08             	mov    0x8(%ebp),%edx
  80131b:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80131d:	85 c0                	test   %eax,%eax
  80131f:	7e 28                	jle    801349 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801321:	89 44 24 10          	mov    %eax,0x10(%esp)
  801325:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  80132c:	00 
  80132d:	c7 44 24 08 eb 35 80 	movl   $0x8035eb,0x8(%esp)
  801334:	00 
  801335:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80133c:	00 
  80133d:	c7 04 24 08 36 80 00 	movl   $0x803608,(%esp)
  801344:	e8 23 f1 ff ff       	call   80046c <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801349:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80134c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80134f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801352:	89 ec                	mov    %ebp,%esp
  801354:	5d                   	pop    %ebp
  801355:	c3                   	ret    

00801356 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801356:	55                   	push   %ebp
  801357:	89 e5                	mov    %esp,%ebp
  801359:	83 ec 38             	sub    $0x38,%esp
  80135c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80135f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801362:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801365:	be 00 00 00 00       	mov    $0x0,%esi
  80136a:	b8 04 00 00 00       	mov    $0x4,%eax
  80136f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801372:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801375:	8b 55 08             	mov    0x8(%ebp),%edx
  801378:	89 f7                	mov    %esi,%edi
  80137a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80137c:	85 c0                	test   %eax,%eax
  80137e:	7e 28                	jle    8013a8 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801380:	89 44 24 10          	mov    %eax,0x10(%esp)
  801384:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80138b:	00 
  80138c:	c7 44 24 08 eb 35 80 	movl   $0x8035eb,0x8(%esp)
  801393:	00 
  801394:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80139b:	00 
  80139c:	c7 04 24 08 36 80 00 	movl   $0x803608,(%esp)
  8013a3:	e8 c4 f0 ff ff       	call   80046c <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  8013a8:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8013ab:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8013ae:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8013b1:	89 ec                	mov    %ebp,%esp
  8013b3:	5d                   	pop    %ebp
  8013b4:	c3                   	ret    

008013b5 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  8013b5:	55                   	push   %ebp
  8013b6:	89 e5                	mov    %esp,%ebp
  8013b8:	83 ec 0c             	sub    $0xc,%esp
  8013bb:	89 1c 24             	mov    %ebx,(%esp)
  8013be:	89 74 24 04          	mov    %esi,0x4(%esp)
  8013c2:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8013c6:	ba 00 00 00 00       	mov    $0x0,%edx
  8013cb:	b8 0b 00 00 00       	mov    $0xb,%eax
  8013d0:	89 d1                	mov    %edx,%ecx
  8013d2:	89 d3                	mov    %edx,%ebx
  8013d4:	89 d7                	mov    %edx,%edi
  8013d6:	89 d6                	mov    %edx,%esi
  8013d8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8013da:	8b 1c 24             	mov    (%esp),%ebx
  8013dd:	8b 74 24 04          	mov    0x4(%esp),%esi
  8013e1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8013e5:	89 ec                	mov    %ebp,%esp
  8013e7:	5d                   	pop    %ebp
  8013e8:	c3                   	ret    

008013e9 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  8013e9:	55                   	push   %ebp
  8013ea:	89 e5                	mov    %esp,%ebp
  8013ec:	83 ec 0c             	sub    $0xc,%esp
  8013ef:	89 1c 24             	mov    %ebx,(%esp)
  8013f2:	89 74 24 04          	mov    %esi,0x4(%esp)
  8013f6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8013fa:	ba 00 00 00 00       	mov    $0x0,%edx
  8013ff:	b8 02 00 00 00       	mov    $0x2,%eax
  801404:	89 d1                	mov    %edx,%ecx
  801406:	89 d3                	mov    %edx,%ebx
  801408:	89 d7                	mov    %edx,%edi
  80140a:	89 d6                	mov    %edx,%esi
  80140c:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  80140e:	8b 1c 24             	mov    (%esp),%ebx
  801411:	8b 74 24 04          	mov    0x4(%esp),%esi
  801415:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801419:	89 ec                	mov    %ebp,%esp
  80141b:	5d                   	pop    %ebp
  80141c:	c3                   	ret    

0080141d <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  80141d:	55                   	push   %ebp
  80141e:	89 e5                	mov    %esp,%ebp
  801420:	83 ec 38             	sub    $0x38,%esp
  801423:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801426:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801429:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80142c:	b9 00 00 00 00       	mov    $0x0,%ecx
  801431:	b8 03 00 00 00       	mov    $0x3,%eax
  801436:	8b 55 08             	mov    0x8(%ebp),%edx
  801439:	89 cb                	mov    %ecx,%ebx
  80143b:	89 cf                	mov    %ecx,%edi
  80143d:	89 ce                	mov    %ecx,%esi
  80143f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801441:	85 c0                	test   %eax,%eax
  801443:	7e 28                	jle    80146d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801445:	89 44 24 10          	mov    %eax,0x10(%esp)
  801449:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801450:	00 
  801451:	c7 44 24 08 eb 35 80 	movl   $0x8035eb,0x8(%esp)
  801458:	00 
  801459:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801460:	00 
  801461:	c7 04 24 08 36 80 00 	movl   $0x803608,(%esp)
  801468:	e8 ff ef ff ff       	call   80046c <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80146d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801470:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801473:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801476:	89 ec                	mov    %ebp,%esp
  801478:	5d                   	pop    %ebp
  801479:	c3                   	ret    
  80147a:	00 00                	add    %al,(%eax)
  80147c:	00 00                	add    %al,(%eax)
	...

00801480 <sfork>:
}

// Challenge!
int
sfork(void)
{
  801480:	55                   	push   %ebp
  801481:	89 e5                	mov    %esp,%ebp
  801483:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  801486:	c7 44 24 08 16 36 80 	movl   $0x803616,0x8(%esp)
  80148d:	00 
  80148e:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  801495:	00 
  801496:	c7 04 24 2c 36 80 00 	movl   $0x80362c,(%esp)
  80149d:	e8 ca ef ff ff       	call   80046c <_panic>

008014a2 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  8014a2:	55                   	push   %ebp
  8014a3:	89 e5                	mov    %esp,%ebp
  8014a5:	57                   	push   %edi
  8014a6:	56                   	push   %esi
  8014a7:	53                   	push   %ebx
  8014a8:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  8014ab:	c7 04 24 0c 17 80 00 	movl   $0x80170c,(%esp)
  8014b2:	e8 bd 17 00 00       	call   802c74 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  8014b7:	ba 07 00 00 00       	mov    $0x7,%edx
  8014bc:	89 d0                	mov    %edx,%eax
  8014be:	cd 30                	int    $0x30
  8014c0:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  8014c3:	85 c0                	test   %eax,%eax
  8014c5:	79 20                	jns    8014e7 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  8014c7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8014cb:	c7 44 24 08 9c 36 80 	movl   $0x80369c,0x8(%esp)
  8014d2:	00 
  8014d3:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  8014da:	00 
  8014db:	c7 04 24 2c 36 80 00 	movl   $0x80362c,(%esp)
  8014e2:	e8 85 ef ff ff       	call   80046c <_panic>
    } else if (childId>0) {
  8014e7:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8014eb:	0f 8e f3 01 00 00    	jle    8016e4 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  8014f1:	c7 44 24 04 e4 2c 80 	movl   $0x802ce4,0x4(%esp)
  8014f8:	00 
  8014f9:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8014fc:	89 04 24             	mov    %eax,(%esp)
  8014ff:	e8 7c fc ff ff       	call   801180 <sys_env_set_pgfault_upcall>
  801504:	85 c0                	test   %eax,%eax
  801506:	74 20                	je     801528 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  801508:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80150c:	c7 44 24 08 c0 36 80 	movl   $0x8036c0,0x8(%esp)
  801513:	00 
  801514:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  80151b:	00 
  80151c:	c7 04 24 2c 36 80 00 	movl   $0x80362c,(%esp)
  801523:	e8 44 ef ff ff       	call   80046c <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  801528:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  80152f:	00 
  801530:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  801537:	ee 
  801538:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80153b:	89 04 24             	mov    %eax,(%esp)
  80153e:	e8 13 fe ff ff       	call   801356 <sys_page_alloc>
  801543:	85 c0                	test   %eax,%eax
  801545:	79 20                	jns    801567 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  801547:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80154b:	c7 44 24 08 f0 36 80 	movl   $0x8036f0,0x8(%esp)
  801552:	00 
  801553:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  80155a:	00 
  80155b:	c7 04 24 2c 36 80 00 	movl   $0x80362c,(%esp)
  801562:	e8 05 ef ff ff       	call   80046c <_panic>
  801567:	be 00 00 80 00       	mov    $0x800000,%esi
  80156c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801571:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801576:	89 f0                	mov    %esi,%eax
  801578:	c1 e8 16             	shr    $0x16,%eax
  80157b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  80157e:	a8 01                	test   $0x1,%al
  801580:	0f 84 13 01 00 00    	je     801699 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  801586:	89 f0                	mov    %esi,%eax
  801588:	c1 e8 0c             	shr    $0xc,%eax
  80158b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801592:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801595:	25 07 0e 00 00       	and    $0xe07,%eax
  80159a:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  80159d:	e8 47 fe ff ff       	call   8013e9 <sys_getenvid>
  8015a2:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  8015a5:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  8015a9:	0f 84 ea 00 00 00    	je     801699 <fork+0x1f7>
  8015af:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  8015b6:	0f 84 9d 00 00 00    	je     801659 <fork+0x1b7>
  8015bc:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  8015c3:	0f 85 90 00 00 00    	jne    801659 <fork+0x1b7>
    perm    &= (~PTE_W);
  8015c9:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8015cc:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  8015cf:	80 cc 08             	or     $0x8,%ah
  8015d2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  8015d5:	89 75 e0             	mov    %esi,-0x20(%ebp)
  8015d8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8015dc:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8015e0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8015e3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8015e7:	89 74 24 04          	mov    %esi,0x4(%esp)
  8015eb:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8015ee:	89 04 24             	mov    %eax,(%esp)
  8015f1:	e8 02 fd ff ff       	call   8012f8 <sys_page_map>
  8015f6:	85 c0                	test   %eax,%eax
  8015f8:	79 1b                	jns    801615 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  8015fa:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8015fe:	89 74 24 08          	mov    %esi,0x8(%esp)
  801602:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801605:	89 44 24 04          	mov    %eax,0x4(%esp)
  801609:	c7 04 24 18 37 80 00 	movl   $0x803718,(%esp)
  801610:	e8 1c ef ff ff       	call   800531 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  801615:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801618:	89 44 24 10          	mov    %eax,0x10(%esp)
  80161c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80161f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801623:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801626:	89 44 24 08          	mov    %eax,0x8(%esp)
  80162a:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80162d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801631:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801634:	89 04 24             	mov    %eax,(%esp)
  801637:	e8 bc fc ff ff       	call   8012f8 <sys_page_map>
  80163c:	85 c0                	test   %eax,%eax
  80163e:	79 59                	jns    801699 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  801640:	89 44 24 08          	mov    %eax,0x8(%esp)
  801644:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801647:	89 44 24 04          	mov    %eax,0x4(%esp)
  80164b:	c7 04 24 58 37 80 00 	movl   $0x803758,(%esp)
  801652:	e8 da ee ff ff       	call   800531 <cprintf>
  801657:	eb 40                	jmp    801699 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801659:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80165c:	89 44 24 10          	mov    %eax,0x10(%esp)
  801660:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801664:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801667:	89 44 24 08          	mov    %eax,0x8(%esp)
  80166b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80166f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801672:	89 04 24             	mov    %eax,(%esp)
  801675:	e8 7e fc ff ff       	call   8012f8 <sys_page_map>
  80167a:	85 c0                	test   %eax,%eax
  80167c:	79 1b                	jns    801699 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80167e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801682:	89 74 24 08          	mov    %esi,0x8(%esp)
  801686:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801689:	89 44 24 04          	mov    %eax,0x4(%esp)
  80168d:	c7 04 24 18 37 80 00 	movl   $0x803718,(%esp)
  801694:	e8 98 ee ff ff       	call   800531 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  801699:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  80169f:	89 de                	mov    %ebx,%esi
  8016a1:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  8016a7:	0f 85 c9 fe ff ff    	jne    801576 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  8016ad:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8016b4:	00 
  8016b5:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8016b8:	89 04 24             	mov    %eax,(%esp)
  8016bb:	e8 7c fb ff ff       	call   80123c <sys_env_set_status>
  8016c0:	85 c0                	test   %eax,%eax
  8016c2:	79 3d                	jns    801701 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  8016c4:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8016c8:	c7 44 24 08 8c 37 80 	movl   $0x80378c,0x8(%esp)
  8016cf:	00 
  8016d0:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  8016d7:	00 
  8016d8:	c7 04 24 2c 36 80 00 	movl   $0x80362c,(%esp)
  8016df:	e8 88 ed ff ff       	call   80046c <_panic>
    } else if (childId==0) {
  8016e4:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8016e8:	75 17                	jne    801701 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  8016ea:	e8 fa fc ff ff       	call   8013e9 <sys_getenvid>
  8016ef:	25 ff 03 00 00       	and    $0x3ff,%eax
  8016f4:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8016f7:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8016fc:	a3 80 74 80 00       	mov    %eax,0x807480
    }
    return childId;
}
  801701:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801704:	83 c4 3c             	add    $0x3c,%esp
  801707:	5b                   	pop    %ebx
  801708:	5e                   	pop    %esi
  801709:	5f                   	pop    %edi
  80170a:	5d                   	pop    %ebp
  80170b:	c3                   	ret    

0080170c <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  80170c:	55                   	push   %ebp
  80170d:	89 e5                	mov    %esp,%ebp
  80170f:	57                   	push   %edi
  801710:	56                   	push   %esi
  801711:	53                   	push   %ebx
  801712:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  801715:	8b 45 08             	mov    0x8(%ebp),%eax
  801718:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  80171a:	8b 50 04             	mov    0x4(%eax),%edx
  80171d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  801720:	89 fe                	mov    %edi,%esi
  801722:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  801728:	e8 bc fc ff ff       	call   8013e9 <sys_getenvid>
  80172d:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  80172f:	89 f2                	mov    %esi,%edx
  801731:	89 f0                	mov    %esi,%eax
  801733:	c1 e8 16             	shr    $0x16,%eax
  801736:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80173d:	a8 01                	test   $0x1,%al
  80173f:	74 3e                	je     80177f <pgfault+0x73>
  801741:	c1 ea 0c             	shr    $0xc,%edx
  801744:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80174b:	a8 01                	test   $0x1,%al
  80174d:	74 30                	je     80177f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  80174f:	c1 ef 0c             	shr    $0xc,%edi
  801752:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  801759:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  80175f:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801762:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801766:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80176d:	00 
  80176e:	89 1c 24             	mov    %ebx,(%esp)
  801771:	e8 e0 fb ff ff       	call   801356 <sys_page_alloc>
  801776:	85 c0                	test   %eax,%eax
  801778:	74 46                	je     8017c0 <pgfault+0xb4>
  80177a:	e9 cd 00 00 00       	jmp    80184c <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  80177f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801782:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801786:	8b 55 08             	mov    0x8(%ebp),%edx
  801789:	8b 42 28             	mov    0x28(%edx),%eax
  80178c:	89 44 24 08          	mov    %eax,0x8(%esp)
  801790:	89 74 24 04          	mov    %esi,0x4(%esp)
  801794:	c7 04 24 ac 37 80 00 	movl   $0x8037ac,(%esp)
  80179b:	e8 91 ed ff ff       	call   800531 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  8017a0:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8017a4:	c7 44 24 08 37 36 80 	movl   $0x803637,0x8(%esp)
  8017ab:	00 
  8017ac:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  8017b3:	00 
  8017b4:	c7 04 24 2c 36 80 00 	movl   $0x80362c,(%esp)
  8017bb:	e8 ac ec ff ff       	call   80046c <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  8017c0:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  8017c7:	00 
  8017c8:	89 74 24 04          	mov    %esi,0x4(%esp)
  8017cc:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  8017d3:	e8 dd f5 ff ff       	call   800db5 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  8017d8:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8017dc:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8017e0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8017e4:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  8017eb:	00 
  8017ec:	89 1c 24             	mov    %ebx,(%esp)
  8017ef:	e8 04 fb ff ff       	call   8012f8 <sys_page_map>
  8017f4:	85 c0                	test   %eax,%eax
  8017f6:	74 20                	je     801818 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  8017f8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8017fc:	c7 44 24 08 49 36 80 	movl   $0x803649,0x8(%esp)
  801803:	00 
  801804:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  80180b:	00 
  80180c:	c7 04 24 2c 36 80 00 	movl   $0x80362c,(%esp)
  801813:	e8 54 ec ff ff       	call   80046c <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  801818:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80181f:	00 
  801820:	89 1c 24             	mov    %ebx,(%esp)
  801823:	e8 72 fa ff ff       	call   80129a <sys_page_unmap>
  801828:	85 c0                	test   %eax,%eax
  80182a:	74 40                	je     80186c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  80182c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801830:	c7 44 24 08 64 36 80 	movl   $0x803664,0x8(%esp)
  801837:	00 
  801838:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  80183f:	00 
  801840:	c7 04 24 2c 36 80 00 	movl   $0x80362c,(%esp)
  801847:	e8 20 ec ff ff       	call   80046c <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  80184c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801850:	c7 44 24 08 81 36 80 	movl   $0x803681,0x8(%esp)
  801857:	00 
  801858:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  80185f:	00 
  801860:	c7 04 24 2c 36 80 00 	movl   $0x80362c,(%esp)
  801867:	e8 00 ec ff ff       	call   80046c <_panic>
}
  80186c:	83 c4 3c             	add    $0x3c,%esp
  80186f:	5b                   	pop    %ebx
  801870:	5e                   	pop    %esi
  801871:	5f                   	pop    %edi
  801872:	5d                   	pop    %ebp
  801873:	c3                   	ret    
	...

00801880 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801880:	55                   	push   %ebp
  801881:	89 e5                	mov    %esp,%ebp
  801883:	8b 45 08             	mov    0x8(%ebp),%eax
  801886:	05 00 00 00 30       	add    $0x30000000,%eax
  80188b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80188e:	5d                   	pop    %ebp
  80188f:	c3                   	ret    

00801890 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801890:	55                   	push   %ebp
  801891:	89 e5                	mov    %esp,%ebp
  801893:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801896:	8b 45 08             	mov    0x8(%ebp),%eax
  801899:	89 04 24             	mov    %eax,(%esp)
  80189c:	e8 df ff ff ff       	call   801880 <fd2num>
  8018a1:	05 20 00 0d 00       	add    $0xd0020,%eax
  8018a6:	c1 e0 0c             	shl    $0xc,%eax
}
  8018a9:	c9                   	leave  
  8018aa:	c3                   	ret    

008018ab <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  8018ab:	55                   	push   %ebp
  8018ac:	89 e5                	mov    %esp,%ebp
  8018ae:	57                   	push   %edi
  8018af:	56                   	push   %esi
  8018b0:	53                   	push   %ebx
  8018b1:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  8018b4:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  8018b9:	a8 01                	test   $0x1,%al
  8018bb:	74 36                	je     8018f3 <fd_alloc+0x48>
  8018bd:	a1 00 00 74 ef       	mov    0xef740000,%eax
  8018c2:	a8 01                	test   $0x1,%al
  8018c4:	74 2d                	je     8018f3 <fd_alloc+0x48>
  8018c6:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  8018cb:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  8018d0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  8018d5:	89 c3                	mov    %eax,%ebx
  8018d7:	89 c2                	mov    %eax,%edx
  8018d9:	c1 ea 16             	shr    $0x16,%edx
  8018dc:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  8018df:	f6 c2 01             	test   $0x1,%dl
  8018e2:	74 14                	je     8018f8 <fd_alloc+0x4d>
  8018e4:	89 c2                	mov    %eax,%edx
  8018e6:	c1 ea 0c             	shr    $0xc,%edx
  8018e9:	8b 14 96             	mov    (%esi,%edx,4),%edx
  8018ec:	f6 c2 01             	test   $0x1,%dl
  8018ef:	75 10                	jne    801901 <fd_alloc+0x56>
  8018f1:	eb 05                	jmp    8018f8 <fd_alloc+0x4d>
  8018f3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  8018f8:	89 1f                	mov    %ebx,(%edi)
  8018fa:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8018ff:	eb 17                	jmp    801918 <fd_alloc+0x6d>
  801901:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  801906:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  80190b:	75 c8                	jne    8018d5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  80190d:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801913:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801918:	5b                   	pop    %ebx
  801919:	5e                   	pop    %esi
  80191a:	5f                   	pop    %edi
  80191b:	5d                   	pop    %ebp
  80191c:	c3                   	ret    

0080191d <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  80191d:	55                   	push   %ebp
  80191e:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801920:	8b 45 08             	mov    0x8(%ebp),%eax
  801923:	83 f8 1f             	cmp    $0x1f,%eax
  801926:	77 36                	ja     80195e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801928:	05 00 00 0d 00       	add    $0xd0000,%eax
  80192d:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801930:	89 c2                	mov    %eax,%edx
  801932:	c1 ea 16             	shr    $0x16,%edx
  801935:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80193c:	f6 c2 01             	test   $0x1,%dl
  80193f:	74 1d                	je     80195e <fd_lookup+0x41>
  801941:	89 c2                	mov    %eax,%edx
  801943:	c1 ea 0c             	shr    $0xc,%edx
  801946:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  80194d:	f6 c2 01             	test   $0x1,%dl
  801950:	74 0c                	je     80195e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801952:	8b 55 0c             	mov    0xc(%ebp),%edx
  801955:	89 02                	mov    %eax,(%edx)
  801957:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  80195c:	eb 05                	jmp    801963 <fd_lookup+0x46>
  80195e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801963:	5d                   	pop    %ebp
  801964:	c3                   	ret    

00801965 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801965:	55                   	push   %ebp
  801966:	89 e5                	mov    %esp,%ebp
  801968:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80196b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80196e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801972:	8b 45 08             	mov    0x8(%ebp),%eax
  801975:	89 04 24             	mov    %eax,(%esp)
  801978:	e8 a0 ff ff ff       	call   80191d <fd_lookup>
  80197d:	85 c0                	test   %eax,%eax
  80197f:	78 0e                	js     80198f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801981:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801984:	8b 55 0c             	mov    0xc(%ebp),%edx
  801987:	89 50 04             	mov    %edx,0x4(%eax)
  80198a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80198f:	c9                   	leave  
  801990:	c3                   	ret    

00801991 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801991:	55                   	push   %ebp
  801992:	89 e5                	mov    %esp,%ebp
  801994:	56                   	push   %esi
  801995:	53                   	push   %ebx
  801996:	83 ec 10             	sub    $0x10,%esp
  801999:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80199c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80199f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  8019a4:	b8 04 70 80 00       	mov    $0x807004,%eax
  8019a9:	39 0d 04 70 80 00    	cmp    %ecx,0x807004
  8019af:	75 11                	jne    8019c2 <dev_lookup+0x31>
  8019b1:	eb 04                	jmp    8019b7 <dev_lookup+0x26>
  8019b3:	39 08                	cmp    %ecx,(%eax)
  8019b5:	75 10                	jne    8019c7 <dev_lookup+0x36>
			*dev = devtab[i];
  8019b7:	89 03                	mov    %eax,(%ebx)
  8019b9:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8019be:	66 90                	xchg   %ax,%ax
  8019c0:	eb 36                	jmp    8019f8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  8019c2:	be 54 38 80 00       	mov    $0x803854,%esi
  8019c7:	83 c2 01             	add    $0x1,%edx
  8019ca:	8b 04 96             	mov    (%esi,%edx,4),%eax
  8019cd:	85 c0                	test   %eax,%eax
  8019cf:	75 e2                	jne    8019b3 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  8019d1:	a1 80 74 80 00       	mov    0x807480,%eax
  8019d6:	8b 40 4c             	mov    0x4c(%eax),%eax
  8019d9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8019dd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019e1:	c7 04 24 d8 37 80 00 	movl   $0x8037d8,(%esp)
  8019e8:	e8 44 eb ff ff       	call   800531 <cprintf>
	*dev = 0;
  8019ed:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8019f3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  8019f8:	83 c4 10             	add    $0x10,%esp
  8019fb:	5b                   	pop    %ebx
  8019fc:	5e                   	pop    %esi
  8019fd:	5d                   	pop    %ebp
  8019fe:	c3                   	ret    

008019ff <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  8019ff:	55                   	push   %ebp
  801a00:	89 e5                	mov    %esp,%ebp
  801a02:	53                   	push   %ebx
  801a03:	83 ec 24             	sub    $0x24,%esp
  801a06:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a09:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801a0c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a10:	8b 45 08             	mov    0x8(%ebp),%eax
  801a13:	89 04 24             	mov    %eax,(%esp)
  801a16:	e8 02 ff ff ff       	call   80191d <fd_lookup>
  801a1b:	85 c0                	test   %eax,%eax
  801a1d:	78 53                	js     801a72 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801a1f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a22:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a26:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801a29:	8b 00                	mov    (%eax),%eax
  801a2b:	89 04 24             	mov    %eax,(%esp)
  801a2e:	e8 5e ff ff ff       	call   801991 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a33:	85 c0                	test   %eax,%eax
  801a35:	78 3b                	js     801a72 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801a37:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801a3c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801a3f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801a43:	74 2d                	je     801a72 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801a45:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801a48:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  801a4f:	00 00 00 
	stat->st_isdir = 0;
  801a52:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801a59:	00 00 00 
	stat->st_dev = dev;
  801a5c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801a5f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801a65:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801a69:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801a6c:	89 14 24             	mov    %edx,(%esp)
  801a6f:	ff 50 14             	call   *0x14(%eax)
}
  801a72:	83 c4 24             	add    $0x24,%esp
  801a75:	5b                   	pop    %ebx
  801a76:	5d                   	pop    %ebp
  801a77:	c3                   	ret    

00801a78 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801a78:	55                   	push   %ebp
  801a79:	89 e5                	mov    %esp,%ebp
  801a7b:	53                   	push   %ebx
  801a7c:	83 ec 24             	sub    $0x24,%esp
  801a7f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a82:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801a85:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a89:	89 1c 24             	mov    %ebx,(%esp)
  801a8c:	e8 8c fe ff ff       	call   80191d <fd_lookup>
  801a91:	85 c0                	test   %eax,%eax
  801a93:	78 5f                	js     801af4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801a95:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a98:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a9c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801a9f:	8b 00                	mov    (%eax),%eax
  801aa1:	89 04 24             	mov    %eax,(%esp)
  801aa4:	e8 e8 fe ff ff       	call   801991 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801aa9:	85 c0                	test   %eax,%eax
  801aab:	78 47                	js     801af4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801aad:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801ab0:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801ab4:	75 23                	jne    801ad9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801ab6:	a1 80 74 80 00       	mov    0x807480,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  801abb:	8b 40 4c             	mov    0x4c(%eax),%eax
  801abe:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801ac2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ac6:	c7 04 24 f8 37 80 00 	movl   $0x8037f8,(%esp)
  801acd:	e8 5f ea ff ff       	call   800531 <cprintf>
  801ad2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801ad7:	eb 1b                	jmp    801af4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801ad9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801adc:	8b 48 18             	mov    0x18(%eax),%ecx
  801adf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801ae4:	85 c9                	test   %ecx,%ecx
  801ae6:	74 0c                	je     801af4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801ae8:	8b 45 0c             	mov    0xc(%ebp),%eax
  801aeb:	89 44 24 04          	mov    %eax,0x4(%esp)
  801aef:	89 14 24             	mov    %edx,(%esp)
  801af2:	ff d1                	call   *%ecx
}
  801af4:	83 c4 24             	add    $0x24,%esp
  801af7:	5b                   	pop    %ebx
  801af8:	5d                   	pop    %ebp
  801af9:	c3                   	ret    

00801afa <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  801afa:	55                   	push   %ebp
  801afb:	89 e5                	mov    %esp,%ebp
  801afd:	53                   	push   %ebx
  801afe:	83 ec 24             	sub    $0x24,%esp
  801b01:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801b04:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801b07:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b0b:	89 1c 24             	mov    %ebx,(%esp)
  801b0e:	e8 0a fe ff ff       	call   80191d <fd_lookup>
  801b13:	85 c0                	test   %eax,%eax
  801b15:	78 66                	js     801b7d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801b17:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801b1a:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b1e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801b21:	8b 00                	mov    (%eax),%eax
  801b23:	89 04 24             	mov    %eax,(%esp)
  801b26:	e8 66 fe ff ff       	call   801991 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801b2b:	85 c0                	test   %eax,%eax
  801b2d:	78 4e                	js     801b7d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801b2f:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801b32:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801b36:	75 23                	jne    801b5b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801b38:	a1 80 74 80 00       	mov    0x807480,%eax
  801b3d:	8b 40 4c             	mov    0x4c(%eax),%eax
  801b40:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801b44:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b48:	c7 04 24 19 38 80 00 	movl   $0x803819,(%esp)
  801b4f:	e8 dd e9 ff ff       	call   800531 <cprintf>
  801b54:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801b59:	eb 22                	jmp    801b7d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  801b5b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801b5e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801b61:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801b66:	85 c9                	test   %ecx,%ecx
  801b68:	74 13                	je     801b7d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  801b6a:	8b 45 10             	mov    0x10(%ebp),%eax
  801b6d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801b71:	8b 45 0c             	mov    0xc(%ebp),%eax
  801b74:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b78:	89 14 24             	mov    %edx,(%esp)
  801b7b:	ff d1                	call   *%ecx
}
  801b7d:	83 c4 24             	add    $0x24,%esp
  801b80:	5b                   	pop    %ebx
  801b81:	5d                   	pop    %ebp
  801b82:	c3                   	ret    

00801b83 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801b83:	55                   	push   %ebp
  801b84:	89 e5                	mov    %esp,%ebp
  801b86:	57                   	push   %edi
  801b87:	56                   	push   %esi
  801b88:	53                   	push   %ebx
  801b89:	83 ec 2c             	sub    $0x2c,%esp
  801b8c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  801b8f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801b92:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801b95:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b99:	89 1c 24             	mov    %ebx,(%esp)
  801b9c:	e8 7c fd ff ff       	call   80191d <fd_lookup>
  801ba1:	85 c0                	test   %eax,%eax
  801ba3:	0f 88 b0 00 00 00    	js     801c59 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801ba9:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801bac:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bb0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801bb3:	8b 00                	mov    (%eax),%eax
  801bb5:	89 04 24             	mov    %eax,(%esp)
  801bb8:	e8 d4 fd ff ff       	call   801991 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801bbd:	85 c0                	test   %eax,%eax
  801bbf:	0f 88 94 00 00 00    	js     801c59 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801bc5:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801bc8:	8b 40 08             	mov    0x8(%eax),%eax
  801bcb:	83 e0 03             	and    $0x3,%eax
  801bce:	83 f8 01             	cmp    $0x1,%eax
  801bd1:	75 23                	jne    801bf6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801bd3:	a1 80 74 80 00       	mov    0x807480,%eax
  801bd8:	8b 40 4c             	mov    0x4c(%eax),%eax
  801bdb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801bdf:	89 44 24 04          	mov    %eax,0x4(%esp)
  801be3:	c7 04 24 36 38 80 00 	movl   $0x803836,(%esp)
  801bea:	e8 42 e9 ff ff       	call   800531 <cprintf>
  801bef:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801bf4:	eb 63                	jmp    801c59 <read+0xd6>
	}
	if (!dev->dev_read)
  801bf6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801bfb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801bfe:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801c02:	74 55                	je     801c59 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801c04:	ba 00 00 00 00       	mov    $0x0,%edx
  801c09:	bb 00 00 00 00       	mov    $0x0,%ebx
  801c0e:	b8 00 00 00 00       	mov    $0x0,%eax
  801c13:	85 f6                	test   %esi,%esi
  801c15:	74 42                	je     801c59 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801c17:	bf 00 10 00 00       	mov    $0x1000,%edi
  801c1c:	89 f0                	mov    %esi,%eax
  801c1e:	29 d0                	sub    %edx,%eax
  801c20:	89 c1                	mov    %eax,%ecx
  801c22:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801c28:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801c2d:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801c30:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801c34:	03 55 0c             	add    0xc(%ebp),%edx
  801c37:	89 54 24 04          	mov    %edx,0x4(%esp)
  801c3b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801c3e:	89 04 24             	mov    %eax,(%esp)
  801c41:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801c44:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801c47:	85 c0                	test   %eax,%eax
  801c49:	78 0e                	js     801c59 <read+0xd6>
			return m;
		if (m == 0)
  801c4b:	85 c0                	test   %eax,%eax
  801c4d:	74 08                	je     801c57 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801c4f:	01 c3                	add    %eax,%ebx
  801c51:	89 da                	mov    %ebx,%edx
  801c53:	39 f3                	cmp    %esi,%ebx
  801c55:	72 c5                	jb     801c1c <read+0x99>
  801c57:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801c59:	83 c4 2c             	add    $0x2c,%esp
  801c5c:	5b                   	pop    %ebx
  801c5d:	5e                   	pop    %esi
  801c5e:	5f                   	pop    %edi
  801c5f:	5d                   	pop    %ebp
  801c60:	c3                   	ret    

00801c61 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801c61:	55                   	push   %ebp
  801c62:	89 e5                	mov    %esp,%ebp
  801c64:	57                   	push   %edi
  801c65:	56                   	push   %esi
  801c66:	53                   	push   %ebx
  801c67:	83 ec 1c             	sub    $0x1c,%esp
  801c6a:	8b 7d 08             	mov    0x8(%ebp),%edi
  801c6d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801c70:	ba 00 00 00 00       	mov    $0x0,%edx
  801c75:	bb 00 00 00 00       	mov    $0x0,%ebx
  801c7a:	b8 00 00 00 00       	mov    $0x0,%eax
  801c7f:	85 f6                	test   %esi,%esi
  801c81:	74 29                	je     801cac <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801c83:	89 f0                	mov    %esi,%eax
  801c85:	29 d0                	sub    %edx,%eax
  801c87:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c8b:	03 55 0c             	add    0xc(%ebp),%edx
  801c8e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801c92:	89 3c 24             	mov    %edi,(%esp)
  801c95:	e8 e9 fe ff ff       	call   801b83 <read>
		if (m < 0)
  801c9a:	85 c0                	test   %eax,%eax
  801c9c:	78 0e                	js     801cac <readn+0x4b>
			return m;
		if (m == 0)
  801c9e:	85 c0                	test   %eax,%eax
  801ca0:	74 08                	je     801caa <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801ca2:	01 c3                	add    %eax,%ebx
  801ca4:	89 da                	mov    %ebx,%edx
  801ca6:	39 f3                	cmp    %esi,%ebx
  801ca8:	72 d9                	jb     801c83 <readn+0x22>
  801caa:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801cac:	83 c4 1c             	add    $0x1c,%esp
  801caf:	5b                   	pop    %ebx
  801cb0:	5e                   	pop    %esi
  801cb1:	5f                   	pop    %edi
  801cb2:	5d                   	pop    %ebp
  801cb3:	c3                   	ret    

00801cb4 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801cb4:	55                   	push   %ebp
  801cb5:	89 e5                	mov    %esp,%ebp
  801cb7:	83 ec 28             	sub    $0x28,%esp
  801cba:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801cbd:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801cc0:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801cc3:	89 34 24             	mov    %esi,(%esp)
  801cc6:	e8 b5 fb ff ff       	call   801880 <fd2num>
  801ccb:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801cce:	89 54 24 04          	mov    %edx,0x4(%esp)
  801cd2:	89 04 24             	mov    %eax,(%esp)
  801cd5:	e8 43 fc ff ff       	call   80191d <fd_lookup>
  801cda:	89 c3                	mov    %eax,%ebx
  801cdc:	85 c0                	test   %eax,%eax
  801cde:	78 05                	js     801ce5 <fd_close+0x31>
  801ce0:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801ce3:	74 0e                	je     801cf3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801ce5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801ce9:	b8 00 00 00 00       	mov    $0x0,%eax
  801cee:	0f 44 d8             	cmove  %eax,%ebx
  801cf1:	eb 3d                	jmp    801d30 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801cf3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801cf6:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cfa:	8b 06                	mov    (%esi),%eax
  801cfc:	89 04 24             	mov    %eax,(%esp)
  801cff:	e8 8d fc ff ff       	call   801991 <dev_lookup>
  801d04:	89 c3                	mov    %eax,%ebx
  801d06:	85 c0                	test   %eax,%eax
  801d08:	78 16                	js     801d20 <fd_close+0x6c>
		if (dev->dev_close)
  801d0a:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801d0d:	8b 40 10             	mov    0x10(%eax),%eax
  801d10:	bb 00 00 00 00       	mov    $0x0,%ebx
  801d15:	85 c0                	test   %eax,%eax
  801d17:	74 07                	je     801d20 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801d19:	89 34 24             	mov    %esi,(%esp)
  801d1c:	ff d0                	call   *%eax
  801d1e:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801d20:	89 74 24 04          	mov    %esi,0x4(%esp)
  801d24:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d2b:	e8 6a f5 ff ff       	call   80129a <sys_page_unmap>
	return r;
}
  801d30:	89 d8                	mov    %ebx,%eax
  801d32:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801d35:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801d38:	89 ec                	mov    %ebp,%esp
  801d3a:	5d                   	pop    %ebp
  801d3b:	c3                   	ret    

00801d3c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  801d3c:	55                   	push   %ebp
  801d3d:	89 e5                	mov    %esp,%ebp
  801d3f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801d42:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d45:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d49:	8b 45 08             	mov    0x8(%ebp),%eax
  801d4c:	89 04 24             	mov    %eax,(%esp)
  801d4f:	e8 c9 fb ff ff       	call   80191d <fd_lookup>
  801d54:	85 c0                	test   %eax,%eax
  801d56:	78 13                	js     801d6b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801d58:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801d5f:	00 
  801d60:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d63:	89 04 24             	mov    %eax,(%esp)
  801d66:	e8 49 ff ff ff       	call   801cb4 <fd_close>
}
  801d6b:	c9                   	leave  
  801d6c:	c3                   	ret    

00801d6d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  801d6d:	55                   	push   %ebp
  801d6e:	89 e5                	mov    %esp,%ebp
  801d70:	83 ec 18             	sub    $0x18,%esp
  801d73:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801d76:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801d79:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801d80:	00 
  801d81:	8b 45 08             	mov    0x8(%ebp),%eax
  801d84:	89 04 24             	mov    %eax,(%esp)
  801d87:	e8 80 03 00 00       	call   80210c <open>
  801d8c:	89 c3                	mov    %eax,%ebx
  801d8e:	85 c0                	test   %eax,%eax
  801d90:	78 1b                	js     801dad <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801d92:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d95:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d99:	89 1c 24             	mov    %ebx,(%esp)
  801d9c:	e8 5e fc ff ff       	call   8019ff <fstat>
  801da1:	89 c6                	mov    %eax,%esi
	close(fd);
  801da3:	89 1c 24             	mov    %ebx,(%esp)
  801da6:	e8 91 ff ff ff       	call   801d3c <close>
  801dab:	89 f3                	mov    %esi,%ebx
	return r;
}
  801dad:	89 d8                	mov    %ebx,%eax
  801daf:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801db2:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801db5:	89 ec                	mov    %ebp,%esp
  801db7:	5d                   	pop    %ebp
  801db8:	c3                   	ret    

00801db9 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801db9:	55                   	push   %ebp
  801dba:	89 e5                	mov    %esp,%ebp
  801dbc:	53                   	push   %ebx
  801dbd:	83 ec 14             	sub    $0x14,%esp
  801dc0:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801dc5:	89 1c 24             	mov    %ebx,(%esp)
  801dc8:	e8 6f ff ff ff       	call   801d3c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  801dcd:	83 c3 01             	add    $0x1,%ebx
  801dd0:	83 fb 20             	cmp    $0x20,%ebx
  801dd3:	75 f0                	jne    801dc5 <close_all+0xc>
		close(i);
}
  801dd5:	83 c4 14             	add    $0x14,%esp
  801dd8:	5b                   	pop    %ebx
  801dd9:	5d                   	pop    %ebp
  801dda:	c3                   	ret    

00801ddb <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801ddb:	55                   	push   %ebp
  801ddc:	89 e5                	mov    %esp,%ebp
  801dde:	83 ec 58             	sub    $0x58,%esp
  801de1:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801de4:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801de7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801dea:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801ded:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801df0:	89 44 24 04          	mov    %eax,0x4(%esp)
  801df4:	8b 45 08             	mov    0x8(%ebp),%eax
  801df7:	89 04 24             	mov    %eax,(%esp)
  801dfa:	e8 1e fb ff ff       	call   80191d <fd_lookup>
  801dff:	89 c3                	mov    %eax,%ebx
  801e01:	85 c0                	test   %eax,%eax
  801e03:	0f 88 e0 00 00 00    	js     801ee9 <dup+0x10e>
		return r;
	close(newfdnum);
  801e09:	89 3c 24             	mov    %edi,(%esp)
  801e0c:	e8 2b ff ff ff       	call   801d3c <close>

	newfd = INDEX2FD(newfdnum);
  801e11:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801e17:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801e1a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801e1d:	89 04 24             	mov    %eax,(%esp)
  801e20:	e8 6b fa ff ff       	call   801890 <fd2data>
  801e25:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801e27:	89 34 24             	mov    %esi,(%esp)
  801e2a:	e8 61 fa ff ff       	call   801890 <fd2data>
  801e2f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801e32:	89 da                	mov    %ebx,%edx
  801e34:	89 d8                	mov    %ebx,%eax
  801e36:	c1 e8 16             	shr    $0x16,%eax
  801e39:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801e40:	a8 01                	test   $0x1,%al
  801e42:	74 43                	je     801e87 <dup+0xac>
  801e44:	c1 ea 0c             	shr    $0xc,%edx
  801e47:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801e4e:	a8 01                	test   $0x1,%al
  801e50:	74 35                	je     801e87 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801e52:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801e59:	25 07 0e 00 00       	and    $0xe07,%eax
  801e5e:	89 44 24 10          	mov    %eax,0x10(%esp)
  801e62:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801e65:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801e69:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801e70:	00 
  801e71:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801e75:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801e7c:	e8 77 f4 ff ff       	call   8012f8 <sys_page_map>
  801e81:	89 c3                	mov    %eax,%ebx
  801e83:	85 c0                	test   %eax,%eax
  801e85:	78 3f                	js     801ec6 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801e87:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801e8a:	89 c2                	mov    %eax,%edx
  801e8c:	c1 ea 0c             	shr    $0xc,%edx
  801e8f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801e96:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801e9c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801ea0:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801ea4:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801eab:	00 
  801eac:	89 44 24 04          	mov    %eax,0x4(%esp)
  801eb0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801eb7:	e8 3c f4 ff ff       	call   8012f8 <sys_page_map>
  801ebc:	89 c3                	mov    %eax,%ebx
  801ebe:	85 c0                	test   %eax,%eax
  801ec0:	78 04                	js     801ec6 <dup+0xeb>
  801ec2:	89 fb                	mov    %edi,%ebx
  801ec4:	eb 23                	jmp    801ee9 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801ec6:	89 74 24 04          	mov    %esi,0x4(%esp)
  801eca:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ed1:	e8 c4 f3 ff ff       	call   80129a <sys_page_unmap>
	sys_page_unmap(0, nva);
  801ed6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801ed9:	89 44 24 04          	mov    %eax,0x4(%esp)
  801edd:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ee4:	e8 b1 f3 ff ff       	call   80129a <sys_page_unmap>
	return r;
}
  801ee9:	89 d8                	mov    %ebx,%eax
  801eeb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801eee:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801ef1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801ef4:	89 ec                	mov    %ebp,%esp
  801ef6:	5d                   	pop    %ebp
  801ef7:	c3                   	ret    

00801ef8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801ef8:	55                   	push   %ebp
  801ef9:	89 e5                	mov    %esp,%ebp
  801efb:	53                   	push   %ebx
  801efc:	83 ec 14             	sub    $0x14,%esp
  801eff:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801f01:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801f07:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801f0e:	00 
  801f0f:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801f16:	00 
  801f17:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f1b:	89 14 24             	mov    %edx,(%esp)
  801f1e:	e8 ed 0d 00 00       	call   802d10 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801f23:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801f2a:	00 
  801f2b:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801f2f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801f36:	e8 47 0e 00 00       	call   802d82 <ipc_recv>
}
  801f3b:	83 c4 14             	add    $0x14,%esp
  801f3e:	5b                   	pop    %ebx
  801f3f:	5d                   	pop    %ebp
  801f40:	c3                   	ret    

00801f41 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801f41:	55                   	push   %ebp
  801f42:	89 e5                	mov    %esp,%ebp
  801f44:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801f47:	8b 45 08             	mov    0x8(%ebp),%eax
  801f4a:	8b 40 0c             	mov    0xc(%eax),%eax
  801f4d:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801f52:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f55:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801f5a:	ba 00 00 00 00       	mov    $0x0,%edx
  801f5f:	b8 02 00 00 00       	mov    $0x2,%eax
  801f64:	e8 8f ff ff ff       	call   801ef8 <fsipc>
}
  801f69:	c9                   	leave  
  801f6a:	c3                   	ret    

00801f6b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801f6b:	55                   	push   %ebp
  801f6c:	89 e5                	mov    %esp,%ebp
  801f6e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801f71:	8b 45 08             	mov    0x8(%ebp),%eax
  801f74:	8b 40 0c             	mov    0xc(%eax),%eax
  801f77:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801f7c:	ba 00 00 00 00       	mov    $0x0,%edx
  801f81:	b8 06 00 00 00       	mov    $0x6,%eax
  801f86:	e8 6d ff ff ff       	call   801ef8 <fsipc>
}
  801f8b:	c9                   	leave  
  801f8c:	c3                   	ret    

00801f8d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801f8d:	55                   	push   %ebp
  801f8e:	89 e5                	mov    %esp,%ebp
  801f90:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801f93:	ba 00 00 00 00       	mov    $0x0,%edx
  801f98:	b8 08 00 00 00       	mov    $0x8,%eax
  801f9d:	e8 56 ff ff ff       	call   801ef8 <fsipc>
}
  801fa2:	c9                   	leave  
  801fa3:	c3                   	ret    

00801fa4 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801fa4:	55                   	push   %ebp
  801fa5:	89 e5                	mov    %esp,%ebp
  801fa7:	53                   	push   %ebx
  801fa8:	83 ec 14             	sub    $0x14,%esp
  801fab:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801fae:	8b 45 08             	mov    0x8(%ebp),%eax
  801fb1:	8b 40 0c             	mov    0xc(%eax),%eax
  801fb4:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801fb9:	ba 00 00 00 00       	mov    $0x0,%edx
  801fbe:	b8 05 00 00 00       	mov    $0x5,%eax
  801fc3:	e8 30 ff ff ff       	call   801ef8 <fsipc>
  801fc8:	85 c0                	test   %eax,%eax
  801fca:	78 2b                	js     801ff7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801fcc:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801fd3:	00 
  801fd4:	89 1c 24             	mov    %ebx,(%esp)
  801fd7:	e8 1e ec ff ff       	call   800bfa <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801fdc:	a1 80 40 80 00       	mov    0x804080,%eax
  801fe1:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801fe7:	a1 84 40 80 00       	mov    0x804084,%eax
  801fec:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801ff2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801ff7:	83 c4 14             	add    $0x14,%esp
  801ffa:	5b                   	pop    %ebx
  801ffb:	5d                   	pop    %ebp
  801ffc:	c3                   	ret    

00801ffd <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801ffd:	55                   	push   %ebp
  801ffe:	89 e5                	mov    %esp,%ebp
  802000:	53                   	push   %ebx
  802001:	83 ec 14             	sub    $0x14,%esp
  802004:	8b 45 08             	mov    0x8(%ebp),%eax
  802007:	8b 55 0c             	mov    0xc(%ebp),%edx
  80200a:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  80200d:	85 c0                	test   %eax,%eax
  80200f:	74 44                	je     802055 <devfile_write+0x58>
  802011:	85 d2                	test   %edx,%edx
  802013:	74 40                	je     802055 <devfile_write+0x58>
  802015:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  80201b:	77 38                	ja     802055 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  80201d:	8b 40 0c             	mov    0xc(%eax),%eax
  802020:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  802025:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  80202b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80202f:	89 54 24 04          	mov    %edx,0x4(%esp)
  802033:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  80203a:	e8 76 ed ff ff       	call   800db5 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  80203f:	ba 00 00 00 00       	mov    $0x0,%edx
  802044:	b8 04 00 00 00       	mov    $0x4,%eax
  802049:	e8 aa fe ff ff       	call   801ef8 <fsipc>
        return r;
    return n;
  80204e:	85 c0                	test   %eax,%eax
  802050:	0f 49 c3             	cmovns %ebx,%eax
  802053:	eb 05                	jmp    80205a <devfile_write+0x5d>
  802055:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  80205a:	83 c4 14             	add    $0x14,%esp
  80205d:	5b                   	pop    %ebx
  80205e:	5d                   	pop    %ebp
  80205f:	c3                   	ret    

00802060 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  802060:	55                   	push   %ebp
  802061:	89 e5                	mov    %esp,%ebp
  802063:	83 ec 18             	sub    $0x18,%esp
  802066:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802069:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80206c:	8b 45 08             	mov    0x8(%ebp),%eax
  80206f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  802072:	85 c0                	test   %eax,%eax
  802074:	74 04                	je     80207a <devfile_read+0x1a>
  802076:	85 f6                	test   %esi,%esi
  802078:	75 07                	jne    802081 <devfile_read+0x21>
  80207a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  80207f:	eb 39                	jmp    8020ba <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  802081:	8b 40 0c             	mov    0xc(%eax),%eax
  802084:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  802089:	8b 45 10             	mov    0x10(%ebp),%eax
  80208c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  802091:	ba 00 00 00 00       	mov    $0x0,%edx
  802096:	b8 03 00 00 00       	mov    $0x3,%eax
  80209b:	e8 58 fe ff ff       	call   801ef8 <fsipc>
  8020a0:	89 c3                	mov    %eax,%ebx
  8020a2:	85 c0                	test   %eax,%eax
  8020a4:	78 14                	js     8020ba <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  8020a6:	89 44 24 08          	mov    %eax,0x8(%esp)
  8020aa:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  8020b1:	00 
  8020b2:	89 34 24             	mov    %esi,(%esp)
  8020b5:	e8 fb ec ff ff       	call   800db5 <memmove>
  return r;
}
  8020ba:	89 d8                	mov    %ebx,%eax
  8020bc:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8020bf:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8020c2:	89 ec                	mov    %ebp,%esp
  8020c4:	5d                   	pop    %ebp
  8020c5:	c3                   	ret    

008020c6 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  8020c6:	55                   	push   %ebp
  8020c7:	89 e5                	mov    %esp,%ebp
  8020c9:	53                   	push   %ebx
  8020ca:	83 ec 14             	sub    $0x14,%esp
  8020cd:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  8020d0:	89 1c 24             	mov    %ebx,(%esp)
  8020d3:	e8 d8 ea ff ff       	call   800bb0 <strlen>
  8020d8:	89 c2                	mov    %eax,%edx
  8020da:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  8020df:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  8020e5:	7f 1f                	jg     802106 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  8020e7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8020eb:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  8020f2:	e8 03 eb ff ff       	call   800bfa <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  8020f7:	ba 00 00 00 00       	mov    $0x0,%edx
  8020fc:	b8 07 00 00 00       	mov    $0x7,%eax
  802101:	e8 f2 fd ff ff       	call   801ef8 <fsipc>
}
  802106:	83 c4 14             	add    $0x14,%esp
  802109:	5b                   	pop    %ebx
  80210a:	5d                   	pop    %ebp
  80210b:	c3                   	ret    

0080210c <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  80210c:	55                   	push   %ebp
  80210d:	89 e5                	mov    %esp,%ebp
  80210f:	83 ec 28             	sub    $0x28,%esp
  802112:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802115:	89 75 fc             	mov    %esi,-0x4(%ebp)
  802118:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  80211b:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  802120:	85 f6                	test   %esi,%esi
  802122:	74 65                	je     802189 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  802124:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  80212b:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80212e:	89 04 24             	mov    %eax,(%esp)
  802131:	e8 75 f7 ff ff       	call   8018ab <fd_alloc>
  802136:	89 c3                	mov    %eax,%ebx
  802138:	85 c0                	test   %eax,%eax
  80213a:	78 4d                	js     802189 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  80213c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802140:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  802147:	e8 ae ea ff ff       	call   800bfa <strcpy>
	fsipcbuf.open.req_omode = mode;
  80214c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80214f:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  802154:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802157:	b8 01 00 00 00       	mov    $0x1,%eax
  80215c:	e8 97 fd ff ff       	call   801ef8 <fsipc>
  802161:	89 c3                	mov    %eax,%ebx
  802163:	85 c0                	test   %eax,%eax
  802165:	79 15                	jns    80217c <open+0x70>
    fd_close(f, 0);
  802167:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80216e:	00 
  80216f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802172:	89 04 24             	mov    %eax,(%esp)
  802175:	e8 3a fb ff ff       	call   801cb4 <fd_close>
    return r;
  80217a:	eb 0d                	jmp    802189 <open+0x7d>
  }
  return fd2num(f);
  80217c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80217f:	89 04 24             	mov    %eax,(%esp)
  802182:	e8 f9 f6 ff ff       	call   801880 <fd2num>
  802187:	89 c3                	mov    %eax,%ebx
}
  802189:	89 d8                	mov    %ebx,%eax
  80218b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80218e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802191:	89 ec                	mov    %ebp,%esp
  802193:	5d                   	pop    %ebp
  802194:	c3                   	ret    
	...

008021a0 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  8021a0:	55                   	push   %ebp
  8021a1:	89 e5                	mov    %esp,%ebp
  8021a3:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  8021a6:	c7 44 24 04 68 38 80 	movl   $0x803868,0x4(%esp)
  8021ad:	00 
  8021ae:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021b1:	89 04 24             	mov    %eax,(%esp)
  8021b4:	e8 41 ea ff ff       	call   800bfa <strcpy>
	return 0;
}
  8021b9:	b8 00 00 00 00       	mov    $0x0,%eax
  8021be:	c9                   	leave  
  8021bf:	c3                   	ret    

008021c0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  8021c0:	55                   	push   %ebp
  8021c1:	89 e5                	mov    %esp,%ebp
  8021c3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  8021c6:	8b 45 08             	mov    0x8(%ebp),%eax
  8021c9:	8b 40 0c             	mov    0xc(%eax),%eax
  8021cc:	89 04 24             	mov    %eax,(%esp)
  8021cf:	e8 9d 02 00 00       	call   802471 <nsipc_close>
}
  8021d4:	c9                   	leave  
  8021d5:	c3                   	ret    

008021d6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8021d6:	55                   	push   %ebp
  8021d7:	89 e5                	mov    %esp,%ebp
  8021d9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8021dc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8021e3:	00 
  8021e4:	8b 45 10             	mov    0x10(%ebp),%eax
  8021e7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8021eb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021ee:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021f2:	8b 45 08             	mov    0x8(%ebp),%eax
  8021f5:	8b 40 0c             	mov    0xc(%eax),%eax
  8021f8:	89 04 24             	mov    %eax,(%esp)
  8021fb:	e8 ad 02 00 00       	call   8024ad <nsipc_send>
}
  802200:	c9                   	leave  
  802201:	c3                   	ret    

00802202 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  802202:	55                   	push   %ebp
  802203:	89 e5                	mov    %esp,%ebp
  802205:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  802208:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80220f:	00 
  802210:	8b 45 10             	mov    0x10(%ebp),%eax
  802213:	89 44 24 08          	mov    %eax,0x8(%esp)
  802217:	8b 45 0c             	mov    0xc(%ebp),%eax
  80221a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80221e:	8b 45 08             	mov    0x8(%ebp),%eax
  802221:	8b 40 0c             	mov    0xc(%eax),%eax
  802224:	89 04 24             	mov    %eax,(%esp)
  802227:	e8 f4 02 00 00       	call   802520 <nsipc_recv>
}
  80222c:	c9                   	leave  
  80222d:	c3                   	ret    

0080222e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  80222e:	55                   	push   %ebp
  80222f:	89 e5                	mov    %esp,%ebp
  802231:	56                   	push   %esi
  802232:	53                   	push   %ebx
  802233:	83 ec 20             	sub    $0x20,%esp
  802236:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802238:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80223b:	89 04 24             	mov    %eax,(%esp)
  80223e:	e8 68 f6 ff ff       	call   8018ab <fd_alloc>
  802243:	89 c3                	mov    %eax,%ebx
  802245:	85 c0                	test   %eax,%eax
  802247:	78 21                	js     80226a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  802249:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802250:	00 
  802251:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802254:	89 44 24 04          	mov    %eax,0x4(%esp)
  802258:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80225f:	e8 f2 f0 ff ff       	call   801356 <sys_page_alloc>
  802264:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802266:	85 c0                	test   %eax,%eax
  802268:	79 0a                	jns    802274 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80226a:	89 34 24             	mov    %esi,(%esp)
  80226d:	e8 ff 01 00 00       	call   802471 <nsipc_close>
		return r;
  802272:	eb 28                	jmp    80229c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  802274:	8b 15 20 70 80 00    	mov    0x807020,%edx
  80227a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80227d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80227f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802282:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  802289:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80228c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  80228f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802292:	89 04 24             	mov    %eax,(%esp)
  802295:	e8 e6 f5 ff ff       	call   801880 <fd2num>
  80229a:	89 c3                	mov    %eax,%ebx
}
  80229c:	89 d8                	mov    %ebx,%eax
  80229e:	83 c4 20             	add    $0x20,%esp
  8022a1:	5b                   	pop    %ebx
  8022a2:	5e                   	pop    %esi
  8022a3:	5d                   	pop    %ebp
  8022a4:	c3                   	ret    

008022a5 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  8022a5:	55                   	push   %ebp
  8022a6:	89 e5                	mov    %esp,%ebp
  8022a8:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  8022ab:	8b 45 10             	mov    0x10(%ebp),%eax
  8022ae:	89 44 24 08          	mov    %eax,0x8(%esp)
  8022b2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8022b5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8022b9:	8b 45 08             	mov    0x8(%ebp),%eax
  8022bc:	89 04 24             	mov    %eax,(%esp)
  8022bf:	e8 61 01 00 00       	call   802425 <nsipc_socket>
  8022c4:	85 c0                	test   %eax,%eax
  8022c6:	78 05                	js     8022cd <socket+0x28>
		return r;
	return alloc_sockfd(r);
  8022c8:	e8 61 ff ff ff       	call   80222e <alloc_sockfd>
}
  8022cd:	c9                   	leave  
  8022ce:	66 90                	xchg   %ax,%ax
  8022d0:	c3                   	ret    

008022d1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  8022d1:	55                   	push   %ebp
  8022d2:	89 e5                	mov    %esp,%ebp
  8022d4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  8022d7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8022da:	89 54 24 04          	mov    %edx,0x4(%esp)
  8022de:	89 04 24             	mov    %eax,(%esp)
  8022e1:	e8 37 f6 ff ff       	call   80191d <fd_lookup>
  8022e6:	85 c0                	test   %eax,%eax
  8022e8:	78 15                	js     8022ff <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  8022ea:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8022ed:	8b 0a                	mov    (%edx),%ecx
  8022ef:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8022f4:	3b 0d 20 70 80 00    	cmp    0x807020,%ecx
  8022fa:	75 03                	jne    8022ff <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  8022fc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  8022ff:	c9                   	leave  
  802300:	c3                   	ret    

00802301 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  802301:	55                   	push   %ebp
  802302:	89 e5                	mov    %esp,%ebp
  802304:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802307:	8b 45 08             	mov    0x8(%ebp),%eax
  80230a:	e8 c2 ff ff ff       	call   8022d1 <fd2sockid>
  80230f:	85 c0                	test   %eax,%eax
  802311:	78 0f                	js     802322 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  802313:	8b 55 0c             	mov    0xc(%ebp),%edx
  802316:	89 54 24 04          	mov    %edx,0x4(%esp)
  80231a:	89 04 24             	mov    %eax,(%esp)
  80231d:	e8 2d 01 00 00       	call   80244f <nsipc_listen>
}
  802322:	c9                   	leave  
  802323:	c3                   	ret    

00802324 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802324:	55                   	push   %ebp
  802325:	89 e5                	mov    %esp,%ebp
  802327:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  80232a:	8b 45 08             	mov    0x8(%ebp),%eax
  80232d:	e8 9f ff ff ff       	call   8022d1 <fd2sockid>
  802332:	85 c0                	test   %eax,%eax
  802334:	78 16                	js     80234c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802336:	8b 55 10             	mov    0x10(%ebp),%edx
  802339:	89 54 24 08          	mov    %edx,0x8(%esp)
  80233d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802340:	89 54 24 04          	mov    %edx,0x4(%esp)
  802344:	89 04 24             	mov    %eax,(%esp)
  802347:	e8 54 02 00 00       	call   8025a0 <nsipc_connect>
}
  80234c:	c9                   	leave  
  80234d:	c3                   	ret    

0080234e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80234e:	55                   	push   %ebp
  80234f:	89 e5                	mov    %esp,%ebp
  802351:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802354:	8b 45 08             	mov    0x8(%ebp),%eax
  802357:	e8 75 ff ff ff       	call   8022d1 <fd2sockid>
  80235c:	85 c0                	test   %eax,%eax
  80235e:	78 0f                	js     80236f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802360:	8b 55 0c             	mov    0xc(%ebp),%edx
  802363:	89 54 24 04          	mov    %edx,0x4(%esp)
  802367:	89 04 24             	mov    %eax,(%esp)
  80236a:	e8 1c 01 00 00       	call   80248b <nsipc_shutdown>
}
  80236f:	c9                   	leave  
  802370:	c3                   	ret    

00802371 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802371:	55                   	push   %ebp
  802372:	89 e5                	mov    %esp,%ebp
  802374:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802377:	8b 45 08             	mov    0x8(%ebp),%eax
  80237a:	e8 52 ff ff ff       	call   8022d1 <fd2sockid>
  80237f:	85 c0                	test   %eax,%eax
  802381:	78 16                	js     802399 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  802383:	8b 55 10             	mov    0x10(%ebp),%edx
  802386:	89 54 24 08          	mov    %edx,0x8(%esp)
  80238a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80238d:	89 54 24 04          	mov    %edx,0x4(%esp)
  802391:	89 04 24             	mov    %eax,(%esp)
  802394:	e8 46 02 00 00       	call   8025df <nsipc_bind>
}
  802399:	c9                   	leave  
  80239a:	c3                   	ret    

0080239b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80239b:	55                   	push   %ebp
  80239c:	89 e5                	mov    %esp,%ebp
  80239e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8023a1:	8b 45 08             	mov    0x8(%ebp),%eax
  8023a4:	e8 28 ff ff ff       	call   8022d1 <fd2sockid>
  8023a9:	85 c0                	test   %eax,%eax
  8023ab:	78 1f                	js     8023cc <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  8023ad:	8b 55 10             	mov    0x10(%ebp),%edx
  8023b0:	89 54 24 08          	mov    %edx,0x8(%esp)
  8023b4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8023b7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8023bb:	89 04 24             	mov    %eax,(%esp)
  8023be:	e8 5b 02 00 00       	call   80261e <nsipc_accept>
  8023c3:	85 c0                	test   %eax,%eax
  8023c5:	78 05                	js     8023cc <accept+0x31>
		return r;
	return alloc_sockfd(r);
  8023c7:	e8 62 fe ff ff       	call   80222e <alloc_sockfd>
}
  8023cc:	c9                   	leave  
  8023cd:	8d 76 00             	lea    0x0(%esi),%esi
  8023d0:	c3                   	ret    
	...

008023e0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  8023e0:	55                   	push   %ebp
  8023e1:	89 e5                	mov    %esp,%ebp
  8023e3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  8023e6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  8023ec:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8023f3:	00 
  8023f4:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  8023fb:	00 
  8023fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  802400:	89 14 24             	mov    %edx,(%esp)
  802403:	e8 08 09 00 00       	call   802d10 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  802408:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80240f:	00 
  802410:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802417:	00 
  802418:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80241b:	89 04 24             	mov    %eax,(%esp)
  80241e:	e8 5f 09 00 00       	call   802d82 <ipc_recv>
    return r;
}
  802423:	c9                   	leave  
  802424:	c3                   	ret    

00802425 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  802425:	55                   	push   %ebp
  802426:	89 e5                	mov    %esp,%ebp
  802428:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  80242b:	8b 45 08             	mov    0x8(%ebp),%eax
  80242e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802433:	8b 45 0c             	mov    0xc(%ebp),%eax
  802436:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  80243b:	8b 45 10             	mov    0x10(%ebp),%eax
  80243e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802443:	b8 09 00 00 00       	mov    $0x9,%eax
  802448:	e8 93 ff ff ff       	call   8023e0 <nsipc>
}
  80244d:	c9                   	leave  
  80244e:	c3                   	ret    

0080244f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80244f:	55                   	push   %ebp
  802450:	89 e5                	mov    %esp,%ebp
  802452:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802455:	8b 45 08             	mov    0x8(%ebp),%eax
  802458:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  80245d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802460:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802465:	b8 06 00 00 00       	mov    $0x6,%eax
  80246a:	e8 71 ff ff ff       	call   8023e0 <nsipc>
}
  80246f:	c9                   	leave  
  802470:	c3                   	ret    

00802471 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802471:	55                   	push   %ebp
  802472:	89 e5                	mov    %esp,%ebp
  802474:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802477:	8b 45 08             	mov    0x8(%ebp),%eax
  80247a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80247f:	b8 04 00 00 00       	mov    $0x4,%eax
  802484:	e8 57 ff ff ff       	call   8023e0 <nsipc>
}
  802489:	c9                   	leave  
  80248a:	c3                   	ret    

0080248b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80248b:	55                   	push   %ebp
  80248c:	89 e5                	mov    %esp,%ebp
  80248e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802491:	8b 45 08             	mov    0x8(%ebp),%eax
  802494:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802499:	8b 45 0c             	mov    0xc(%ebp),%eax
  80249c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  8024a1:	b8 03 00 00 00       	mov    $0x3,%eax
  8024a6:	e8 35 ff ff ff       	call   8023e0 <nsipc>
}
  8024ab:	c9                   	leave  
  8024ac:	c3                   	ret    

008024ad <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  8024ad:	55                   	push   %ebp
  8024ae:	89 e5                	mov    %esp,%ebp
  8024b0:	53                   	push   %ebx
  8024b1:	83 ec 14             	sub    $0x14,%esp
  8024b4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  8024b7:	8b 45 08             	mov    0x8(%ebp),%eax
  8024ba:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  8024bf:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  8024c5:	7e 24                	jle    8024eb <nsipc_send+0x3e>
  8024c7:	c7 44 24 0c 74 38 80 	movl   $0x803874,0xc(%esp)
  8024ce:	00 
  8024cf:	c7 44 24 08 80 38 80 	movl   $0x803880,0x8(%esp)
  8024d6:	00 
  8024d7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8024de:	00 
  8024df:	c7 04 24 95 38 80 00 	movl   $0x803895,(%esp)
  8024e6:	e8 81 df ff ff       	call   80046c <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  8024eb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8024ef:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024f2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024f6:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  8024fd:	e8 b3 e8 ff ff       	call   800db5 <memmove>
	nsipcbuf.send.req_size = size;
  802502:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  802508:	8b 45 14             	mov    0x14(%ebp),%eax
  80250b:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  802510:	b8 08 00 00 00       	mov    $0x8,%eax
  802515:	e8 c6 fe ff ff       	call   8023e0 <nsipc>
}
  80251a:	83 c4 14             	add    $0x14,%esp
  80251d:	5b                   	pop    %ebx
  80251e:	5d                   	pop    %ebp
  80251f:	c3                   	ret    

00802520 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802520:	55                   	push   %ebp
  802521:	89 e5                	mov    %esp,%ebp
  802523:	56                   	push   %esi
  802524:	53                   	push   %ebx
  802525:	83 ec 10             	sub    $0x10,%esp
  802528:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80252b:	8b 45 08             	mov    0x8(%ebp),%eax
  80252e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802533:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802539:	8b 45 14             	mov    0x14(%ebp),%eax
  80253c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802541:	b8 07 00 00 00       	mov    $0x7,%eax
  802546:	e8 95 fe ff ff       	call   8023e0 <nsipc>
  80254b:	89 c3                	mov    %eax,%ebx
  80254d:	85 c0                	test   %eax,%eax
  80254f:	78 46                	js     802597 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802551:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802556:	7f 04                	jg     80255c <nsipc_recv+0x3c>
  802558:	39 c6                	cmp    %eax,%esi
  80255a:	7d 24                	jge    802580 <nsipc_recv+0x60>
  80255c:	c7 44 24 0c a1 38 80 	movl   $0x8038a1,0xc(%esp)
  802563:	00 
  802564:	c7 44 24 08 80 38 80 	movl   $0x803880,0x8(%esp)
  80256b:	00 
  80256c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802573:	00 
  802574:	c7 04 24 95 38 80 00 	movl   $0x803895,(%esp)
  80257b:	e8 ec de ff ff       	call   80046c <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802580:	89 44 24 08          	mov    %eax,0x8(%esp)
  802584:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  80258b:	00 
  80258c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80258f:	89 04 24             	mov    %eax,(%esp)
  802592:	e8 1e e8 ff ff       	call   800db5 <memmove>
	}

	return r;
}
  802597:	89 d8                	mov    %ebx,%eax
  802599:	83 c4 10             	add    $0x10,%esp
  80259c:	5b                   	pop    %ebx
  80259d:	5e                   	pop    %esi
  80259e:	5d                   	pop    %ebp
  80259f:	c3                   	ret    

008025a0 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8025a0:	55                   	push   %ebp
  8025a1:	89 e5                	mov    %esp,%ebp
  8025a3:	53                   	push   %ebx
  8025a4:	83 ec 14             	sub    $0x14,%esp
  8025a7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  8025aa:	8b 45 08             	mov    0x8(%ebp),%eax
  8025ad:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  8025b2:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8025b6:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025bd:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8025c4:	e8 ec e7 ff ff       	call   800db5 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  8025c9:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  8025cf:	b8 05 00 00 00       	mov    $0x5,%eax
  8025d4:	e8 07 fe ff ff       	call   8023e0 <nsipc>
}
  8025d9:	83 c4 14             	add    $0x14,%esp
  8025dc:	5b                   	pop    %ebx
  8025dd:	5d                   	pop    %ebp
  8025de:	c3                   	ret    

008025df <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8025df:	55                   	push   %ebp
  8025e0:	89 e5                	mov    %esp,%ebp
  8025e2:	53                   	push   %ebx
  8025e3:	83 ec 14             	sub    $0x14,%esp
  8025e6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8025e9:	8b 45 08             	mov    0x8(%ebp),%eax
  8025ec:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8025f1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8025f5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025f8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025fc:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802603:	e8 ad e7 ff ff       	call   800db5 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802608:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  80260e:	b8 02 00 00 00       	mov    $0x2,%eax
  802613:	e8 c8 fd ff ff       	call   8023e0 <nsipc>
}
  802618:	83 c4 14             	add    $0x14,%esp
  80261b:	5b                   	pop    %ebx
  80261c:	5d                   	pop    %ebp
  80261d:	c3                   	ret    

0080261e <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80261e:	55                   	push   %ebp
  80261f:	89 e5                	mov    %esp,%ebp
  802621:	83 ec 18             	sub    $0x18,%esp
  802624:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802627:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  80262a:	8b 45 08             	mov    0x8(%ebp),%eax
  80262d:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802632:	b8 01 00 00 00       	mov    $0x1,%eax
  802637:	e8 a4 fd ff ff       	call   8023e0 <nsipc>
  80263c:	89 c3                	mov    %eax,%ebx
  80263e:	85 c0                	test   %eax,%eax
  802640:	78 25                	js     802667 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802642:	be 10 60 80 00       	mov    $0x806010,%esi
  802647:	8b 06                	mov    (%esi),%eax
  802649:	89 44 24 08          	mov    %eax,0x8(%esp)
  80264d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802654:	00 
  802655:	8b 45 0c             	mov    0xc(%ebp),%eax
  802658:	89 04 24             	mov    %eax,(%esp)
  80265b:	e8 55 e7 ff ff       	call   800db5 <memmove>
		*addrlen = ret->ret_addrlen;
  802660:	8b 16                	mov    (%esi),%edx
  802662:	8b 45 10             	mov    0x10(%ebp),%eax
  802665:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802667:	89 d8                	mov    %ebx,%eax
  802669:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80266c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80266f:	89 ec                	mov    %ebp,%esp
  802671:	5d                   	pop    %ebp
  802672:	c3                   	ret    
	...

00802680 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802680:	55                   	push   %ebp
  802681:	89 e5                	mov    %esp,%ebp
  802683:	83 ec 18             	sub    $0x18,%esp
  802686:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802689:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80268c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80268f:	8b 45 08             	mov    0x8(%ebp),%eax
  802692:	89 04 24             	mov    %eax,(%esp)
  802695:	e8 f6 f1 ff ff       	call   801890 <fd2data>
  80269a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80269c:	c7 44 24 04 b6 38 80 	movl   $0x8038b6,0x4(%esp)
  8026a3:	00 
  8026a4:	89 34 24             	mov    %esi,(%esp)
  8026a7:	e8 4e e5 ff ff       	call   800bfa <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  8026ac:	8b 43 04             	mov    0x4(%ebx),%eax
  8026af:	2b 03                	sub    (%ebx),%eax
  8026b1:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  8026b7:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  8026be:	00 00 00 
	stat->st_dev = &devpipe;
  8026c1:	c7 86 88 00 00 00 3c 	movl   $0x80703c,0x88(%esi)
  8026c8:	70 80 00 
	return 0;
}
  8026cb:	b8 00 00 00 00       	mov    $0x0,%eax
  8026d0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8026d3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8026d6:	89 ec                	mov    %ebp,%esp
  8026d8:	5d                   	pop    %ebp
  8026d9:	c3                   	ret    

008026da <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8026da:	55                   	push   %ebp
  8026db:	89 e5                	mov    %esp,%ebp
  8026dd:	53                   	push   %ebx
  8026de:	83 ec 14             	sub    $0x14,%esp
  8026e1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  8026e4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8026e8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026ef:	e8 a6 eb ff ff       	call   80129a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8026f4:	89 1c 24             	mov    %ebx,(%esp)
  8026f7:	e8 94 f1 ff ff       	call   801890 <fd2data>
  8026fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  802700:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802707:	e8 8e eb ff ff       	call   80129a <sys_page_unmap>
}
  80270c:	83 c4 14             	add    $0x14,%esp
  80270f:	5b                   	pop    %ebx
  802710:	5d                   	pop    %ebp
  802711:	c3                   	ret    

00802712 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  802712:	55                   	push   %ebp
  802713:	89 e5                	mov    %esp,%ebp
  802715:	57                   	push   %edi
  802716:	56                   	push   %esi
  802717:	53                   	push   %ebx
  802718:	83 ec 2c             	sub    $0x2c,%esp
  80271b:	89 c7                	mov    %eax,%edi
  80271d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802720:	a1 80 74 80 00       	mov    0x807480,%eax
  802725:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802728:	89 3c 24             	mov    %edi,(%esp)
  80272b:	e8 a4 06 00 00       	call   802dd4 <pageref>
  802730:	89 c6                	mov    %eax,%esi
  802732:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802735:	89 04 24             	mov    %eax,(%esp)
  802738:	e8 97 06 00 00       	call   802dd4 <pageref>
  80273d:	39 c6                	cmp    %eax,%esi
  80273f:	0f 94 c0             	sete   %al
  802742:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802745:	8b 15 80 74 80 00    	mov    0x807480,%edx
  80274b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80274e:	39 cb                	cmp    %ecx,%ebx
  802750:	75 08                	jne    80275a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802752:	83 c4 2c             	add    $0x2c,%esp
  802755:	5b                   	pop    %ebx
  802756:	5e                   	pop    %esi
  802757:	5f                   	pop    %edi
  802758:	5d                   	pop    %ebp
  802759:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80275a:	83 f8 01             	cmp    $0x1,%eax
  80275d:	75 c1                	jne    802720 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80275f:	8b 52 58             	mov    0x58(%edx),%edx
  802762:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802766:	89 54 24 08          	mov    %edx,0x8(%esp)
  80276a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80276e:	c7 04 24 bd 38 80 00 	movl   $0x8038bd,(%esp)
  802775:	e8 b7 dd ff ff       	call   800531 <cprintf>
  80277a:	eb a4                	jmp    802720 <_pipeisclosed+0xe>

0080277c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80277c:	55                   	push   %ebp
  80277d:	89 e5                	mov    %esp,%ebp
  80277f:	57                   	push   %edi
  802780:	56                   	push   %esi
  802781:	53                   	push   %ebx
  802782:	83 ec 1c             	sub    $0x1c,%esp
  802785:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802788:	89 34 24             	mov    %esi,(%esp)
  80278b:	e8 00 f1 ff ff       	call   801890 <fd2data>
  802790:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802792:	bf 00 00 00 00       	mov    $0x0,%edi
  802797:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80279b:	75 54                	jne    8027f1 <devpipe_write+0x75>
  80279d:	eb 60                	jmp    8027ff <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80279f:	89 da                	mov    %ebx,%edx
  8027a1:	89 f0                	mov    %esi,%eax
  8027a3:	e8 6a ff ff ff       	call   802712 <_pipeisclosed>
  8027a8:	85 c0                	test   %eax,%eax
  8027aa:	74 07                	je     8027b3 <devpipe_write+0x37>
  8027ac:	b8 00 00 00 00       	mov    $0x0,%eax
  8027b1:	eb 53                	jmp    802806 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  8027b3:	90                   	nop
  8027b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8027b8:	e8 f8 eb ff ff       	call   8013b5 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8027bd:	8b 43 04             	mov    0x4(%ebx),%eax
  8027c0:	8b 13                	mov    (%ebx),%edx
  8027c2:	83 c2 20             	add    $0x20,%edx
  8027c5:	39 d0                	cmp    %edx,%eax
  8027c7:	73 d6                	jae    80279f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  8027c9:	89 c2                	mov    %eax,%edx
  8027cb:	c1 fa 1f             	sar    $0x1f,%edx
  8027ce:	c1 ea 1b             	shr    $0x1b,%edx
  8027d1:	01 d0                	add    %edx,%eax
  8027d3:	83 e0 1f             	and    $0x1f,%eax
  8027d6:	29 d0                	sub    %edx,%eax
  8027d8:	89 c2                	mov    %eax,%edx
  8027da:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8027dd:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  8027e1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  8027e5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8027e9:	83 c7 01             	add    $0x1,%edi
  8027ec:	39 7d 10             	cmp    %edi,0x10(%ebp)
  8027ef:	76 13                	jbe    802804 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8027f1:	8b 43 04             	mov    0x4(%ebx),%eax
  8027f4:	8b 13                	mov    (%ebx),%edx
  8027f6:	83 c2 20             	add    $0x20,%edx
  8027f9:	39 d0                	cmp    %edx,%eax
  8027fb:	73 a2                	jae    80279f <devpipe_write+0x23>
  8027fd:	eb ca                	jmp    8027c9 <devpipe_write+0x4d>
  8027ff:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802804:	89 f8                	mov    %edi,%eax
}
  802806:	83 c4 1c             	add    $0x1c,%esp
  802809:	5b                   	pop    %ebx
  80280a:	5e                   	pop    %esi
  80280b:	5f                   	pop    %edi
  80280c:	5d                   	pop    %ebp
  80280d:	c3                   	ret    

0080280e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  80280e:	55                   	push   %ebp
  80280f:	89 e5                	mov    %esp,%ebp
  802811:	83 ec 28             	sub    $0x28,%esp
  802814:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802817:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80281a:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80281d:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  802820:	89 3c 24             	mov    %edi,(%esp)
  802823:	e8 68 f0 ff ff       	call   801890 <fd2data>
  802828:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  80282a:	be 00 00 00 00       	mov    $0x0,%esi
  80282f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802833:	75 4c                	jne    802881 <devpipe_read+0x73>
  802835:	eb 5b                	jmp    802892 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802837:	89 f0                	mov    %esi,%eax
  802839:	eb 5e                	jmp    802899 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80283b:	89 da                	mov    %ebx,%edx
  80283d:	89 f8                	mov    %edi,%eax
  80283f:	90                   	nop
  802840:	e8 cd fe ff ff       	call   802712 <_pipeisclosed>
  802845:	85 c0                	test   %eax,%eax
  802847:	74 07                	je     802850 <devpipe_read+0x42>
  802849:	b8 00 00 00 00       	mov    $0x0,%eax
  80284e:	eb 49                	jmp    802899 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802850:	e8 60 eb ff ff       	call   8013b5 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802855:	8b 03                	mov    (%ebx),%eax
  802857:	3b 43 04             	cmp    0x4(%ebx),%eax
  80285a:	74 df                	je     80283b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80285c:	89 c2                	mov    %eax,%edx
  80285e:	c1 fa 1f             	sar    $0x1f,%edx
  802861:	c1 ea 1b             	shr    $0x1b,%edx
  802864:	01 d0                	add    %edx,%eax
  802866:	83 e0 1f             	and    $0x1f,%eax
  802869:	29 d0                	sub    %edx,%eax
  80286b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802870:	8b 55 0c             	mov    0xc(%ebp),%edx
  802873:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802876:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802879:	83 c6 01             	add    $0x1,%esi
  80287c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80287f:	76 16                	jbe    802897 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802881:	8b 03                	mov    (%ebx),%eax
  802883:	3b 43 04             	cmp    0x4(%ebx),%eax
  802886:	75 d4                	jne    80285c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802888:	85 f6                	test   %esi,%esi
  80288a:	75 ab                	jne    802837 <devpipe_read+0x29>
  80288c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802890:	eb a9                	jmp    80283b <devpipe_read+0x2d>
  802892:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802897:	89 f0                	mov    %esi,%eax
}
  802899:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80289c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80289f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8028a2:	89 ec                	mov    %ebp,%esp
  8028a4:	5d                   	pop    %ebp
  8028a5:	c3                   	ret    

008028a6 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  8028a6:	55                   	push   %ebp
  8028a7:	89 e5                	mov    %esp,%ebp
  8028a9:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8028ac:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8028af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028b3:	8b 45 08             	mov    0x8(%ebp),%eax
  8028b6:	89 04 24             	mov    %eax,(%esp)
  8028b9:	e8 5f f0 ff ff       	call   80191d <fd_lookup>
  8028be:	85 c0                	test   %eax,%eax
  8028c0:	78 15                	js     8028d7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  8028c2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8028c5:	89 04 24             	mov    %eax,(%esp)
  8028c8:	e8 c3 ef ff ff       	call   801890 <fd2data>
	return _pipeisclosed(fd, p);
  8028cd:	89 c2                	mov    %eax,%edx
  8028cf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8028d2:	e8 3b fe ff ff       	call   802712 <_pipeisclosed>
}
  8028d7:	c9                   	leave  
  8028d8:	c3                   	ret    

008028d9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8028d9:	55                   	push   %ebp
  8028da:	89 e5                	mov    %esp,%ebp
  8028dc:	83 ec 48             	sub    $0x48,%esp
  8028df:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8028e2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8028e5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8028e8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8028eb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8028ee:	89 04 24             	mov    %eax,(%esp)
  8028f1:	e8 b5 ef ff ff       	call   8018ab <fd_alloc>
  8028f6:	89 c3                	mov    %eax,%ebx
  8028f8:	85 c0                	test   %eax,%eax
  8028fa:	0f 88 42 01 00 00    	js     802a42 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802900:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802907:	00 
  802908:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80290b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80290f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802916:	e8 3b ea ff ff       	call   801356 <sys_page_alloc>
  80291b:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80291d:	85 c0                	test   %eax,%eax
  80291f:	0f 88 1d 01 00 00    	js     802a42 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802925:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802928:	89 04 24             	mov    %eax,(%esp)
  80292b:	e8 7b ef ff ff       	call   8018ab <fd_alloc>
  802930:	89 c3                	mov    %eax,%ebx
  802932:	85 c0                	test   %eax,%eax
  802934:	0f 88 f5 00 00 00    	js     802a2f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80293a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802941:	00 
  802942:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802945:	89 44 24 04          	mov    %eax,0x4(%esp)
  802949:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802950:	e8 01 ea ff ff       	call   801356 <sys_page_alloc>
  802955:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802957:	85 c0                	test   %eax,%eax
  802959:	0f 88 d0 00 00 00    	js     802a2f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80295f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802962:	89 04 24             	mov    %eax,(%esp)
  802965:	e8 26 ef ff ff       	call   801890 <fd2data>
  80296a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80296c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802973:	00 
  802974:	89 44 24 04          	mov    %eax,0x4(%esp)
  802978:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80297f:	e8 d2 e9 ff ff       	call   801356 <sys_page_alloc>
  802984:	89 c3                	mov    %eax,%ebx
  802986:	85 c0                	test   %eax,%eax
  802988:	0f 88 8e 00 00 00    	js     802a1c <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80298e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802991:	89 04 24             	mov    %eax,(%esp)
  802994:	e8 f7 ee ff ff       	call   801890 <fd2data>
  802999:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  8029a0:	00 
  8029a1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8029a5:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8029ac:	00 
  8029ad:	89 74 24 04          	mov    %esi,0x4(%esp)
  8029b1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8029b8:	e8 3b e9 ff ff       	call   8012f8 <sys_page_map>
  8029bd:	89 c3                	mov    %eax,%ebx
  8029bf:	85 c0                	test   %eax,%eax
  8029c1:	78 49                	js     802a0c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  8029c3:	b8 3c 70 80 00       	mov    $0x80703c,%eax
  8029c8:	8b 08                	mov    (%eax),%ecx
  8029ca:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8029cd:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  8029cf:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8029d2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8029d9:	8b 10                	mov    (%eax),%edx
  8029db:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8029de:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  8029e0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8029e3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  8029ea:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8029ed:	89 04 24             	mov    %eax,(%esp)
  8029f0:	e8 8b ee ff ff       	call   801880 <fd2num>
  8029f5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8029f7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8029fa:	89 04 24             	mov    %eax,(%esp)
  8029fd:	e8 7e ee ff ff       	call   801880 <fd2num>
  802a02:	89 47 04             	mov    %eax,0x4(%edi)
  802a05:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  802a0a:	eb 36                	jmp    802a42 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  802a0c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802a10:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802a17:	e8 7e e8 ff ff       	call   80129a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  802a1c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802a1f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a23:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802a2a:	e8 6b e8 ff ff       	call   80129a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  802a2f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802a32:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a36:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802a3d:	e8 58 e8 ff ff       	call   80129a <sys_page_unmap>
    err:
	return r;
}
  802a42:	89 d8                	mov    %ebx,%eax
  802a44:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802a47:	8b 75 f8             	mov    -0x8(%ebp),%esi
  802a4a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802a4d:	89 ec                	mov    %ebp,%esp
  802a4f:	5d                   	pop    %ebp
  802a50:	c3                   	ret    
  802a51:	00 00                	add    %al,(%eax)
	...

00802a54 <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  802a54:	55                   	push   %ebp
  802a55:	89 e5                	mov    %esp,%ebp
  802a57:	56                   	push   %esi
  802a58:	53                   	push   %ebx
  802a59:	83 ec 10             	sub    $0x10,%esp
  802a5c:	8b 45 08             	mov    0x8(%ebp),%eax
	volatile struct Env *e;

	assert(envid != 0);
  802a5f:	85 c0                	test   %eax,%eax
  802a61:	75 24                	jne    802a87 <wait+0x33>
  802a63:	c7 44 24 0c d5 38 80 	movl   $0x8038d5,0xc(%esp)
  802a6a:	00 
  802a6b:	c7 44 24 08 80 38 80 	movl   $0x803880,0x8(%esp)
  802a72:	00 
  802a73:	c7 44 24 04 09 00 00 	movl   $0x9,0x4(%esp)
  802a7a:	00 
  802a7b:	c7 04 24 e0 38 80 00 	movl   $0x8038e0,(%esp)
  802a82:	e8 e5 d9 ff ff       	call   80046c <_panic>
	e = &envs[ENVX(envid)];
  802a87:	89 c3                	mov    %eax,%ebx
  802a89:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
  802a8f:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  802a92:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  802a98:	8b 73 4c             	mov    0x4c(%ebx),%esi
  802a9b:	39 c6                	cmp    %eax,%esi
  802a9d:	75 1a                	jne    802ab9 <wait+0x65>
  802a9f:	8b 43 54             	mov    0x54(%ebx),%eax
  802aa2:	85 c0                	test   %eax,%eax
  802aa4:	74 13                	je     802ab9 <wait+0x65>
		sys_yield();
  802aa6:	e8 0a e9 ff ff       	call   8013b5 <sys_yield>
{
	volatile struct Env *e;

	assert(envid != 0);
	e = &envs[ENVX(envid)];
	while (e->env_id == envid && e->env_status != ENV_FREE)
  802aab:	8b 43 4c             	mov    0x4c(%ebx),%eax
  802aae:	39 f0                	cmp    %esi,%eax
  802ab0:	75 07                	jne    802ab9 <wait+0x65>
  802ab2:	8b 43 54             	mov    0x54(%ebx),%eax
  802ab5:	85 c0                	test   %eax,%eax
  802ab7:	75 ed                	jne    802aa6 <wait+0x52>
		sys_yield();
}
  802ab9:	83 c4 10             	add    $0x10,%esp
  802abc:	5b                   	pop    %ebx
  802abd:	5e                   	pop    %esi
  802abe:	5d                   	pop    %ebp
  802abf:	c3                   	ret    

00802ac0 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802ac0:	55                   	push   %ebp
  802ac1:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802ac3:	b8 00 00 00 00       	mov    $0x0,%eax
  802ac8:	5d                   	pop    %ebp
  802ac9:	c3                   	ret    

00802aca <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  802aca:	55                   	push   %ebp
  802acb:	89 e5                	mov    %esp,%ebp
  802acd:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802ad0:	c7 44 24 04 eb 38 80 	movl   $0x8038eb,0x4(%esp)
  802ad7:	00 
  802ad8:	8b 45 0c             	mov    0xc(%ebp),%eax
  802adb:	89 04 24             	mov    %eax,(%esp)
  802ade:	e8 17 e1 ff ff       	call   800bfa <strcpy>
	return 0;
}
  802ae3:	b8 00 00 00 00       	mov    $0x0,%eax
  802ae8:	c9                   	leave  
  802ae9:	c3                   	ret    

00802aea <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  802aea:	55                   	push   %ebp
  802aeb:	89 e5                	mov    %esp,%ebp
  802aed:	57                   	push   %edi
  802aee:	56                   	push   %esi
  802aef:	53                   	push   %ebx
  802af0:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802af6:	b8 00 00 00 00       	mov    $0x0,%eax
  802afb:	be 00 00 00 00       	mov    $0x0,%esi
  802b00:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802b04:	74 41                	je     802b47 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802b06:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  802b0c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  802b0f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802b11:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802b17:	ba 7f 00 00 00       	mov    $0x7f,%edx
  802b1c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802b1f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802b23:	03 45 0c             	add    0xc(%ebp),%eax
  802b26:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b2a:	89 3c 24             	mov    %edi,(%esp)
  802b2d:	e8 83 e2 ff ff       	call   800db5 <memmove>
		sys_cputs(buf, m);
  802b32:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802b36:	89 3c 24             	mov    %edi,(%esp)
  802b39:	e8 b2 e4 ff ff       	call   800ff0 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802b3e:	01 de                	add    %ebx,%esi
  802b40:	89 f0                	mov    %esi,%eax
  802b42:	3b 75 10             	cmp    0x10(%ebp),%esi
  802b45:	72 c5                	jb     802b0c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802b47:	89 f0                	mov    %esi,%eax
  802b49:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  802b4f:	5b                   	pop    %ebx
  802b50:	5e                   	pop    %esi
  802b51:	5f                   	pop    %edi
  802b52:	5d                   	pop    %ebp
  802b53:	c3                   	ret    

00802b54 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  802b54:	55                   	push   %ebp
  802b55:	89 e5                	mov    %esp,%ebp
  802b57:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  802b5a:	8b 45 08             	mov    0x8(%ebp),%eax
  802b5d:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  802b60:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802b67:	00 
  802b68:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802b6b:	89 04 24             	mov    %eax,(%esp)
  802b6e:	e8 7d e4 ff ff       	call   800ff0 <sys_cputs>
}
  802b73:	c9                   	leave  
  802b74:	c3                   	ret    

00802b75 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  802b75:	55                   	push   %ebp
  802b76:	89 e5                	mov    %esp,%ebp
  802b78:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  802b7b:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802b7f:	75 07                	jne    802b88 <devcons_read+0x13>
  802b81:	eb 2d                	jmp    802bb0 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  802b83:	e8 2d e8 ff ff       	call   8013b5 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  802b88:	90                   	nop
  802b89:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802b90:	e8 27 e4 ff ff       	call   800fbc <sys_cgetc>
  802b95:	85 c0                	test   %eax,%eax
  802b97:	74 ea                	je     802b83 <devcons_read+0xe>
  802b99:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  802b9b:	85 c0                	test   %eax,%eax
  802b9d:	78 16                	js     802bb5 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  802b9f:	83 f8 04             	cmp    $0x4,%eax
  802ba2:	74 0c                	je     802bb0 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802ba4:	8b 45 0c             	mov    0xc(%ebp),%eax
  802ba7:	88 10                	mov    %dl,(%eax)
  802ba9:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  802bae:	eb 05                	jmp    802bb5 <devcons_read+0x40>
  802bb0:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802bb5:	c9                   	leave  
  802bb6:	c3                   	ret    

00802bb7 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802bb7:	55                   	push   %ebp
  802bb8:	89 e5                	mov    %esp,%ebp
  802bba:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  802bbd:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802bc0:	89 04 24             	mov    %eax,(%esp)
  802bc3:	e8 e3 ec ff ff       	call   8018ab <fd_alloc>
  802bc8:	85 c0                	test   %eax,%eax
  802bca:	78 3f                	js     802c0b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  802bcc:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802bd3:	00 
  802bd4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802bd7:	89 44 24 04          	mov    %eax,0x4(%esp)
  802bdb:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802be2:	e8 6f e7 ff ff       	call   801356 <sys_page_alloc>
  802be7:	85 c0                	test   %eax,%eax
  802be9:	78 20                	js     802c0b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  802beb:	8b 15 58 70 80 00    	mov    0x807058,%edx
  802bf1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802bf4:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802bf6:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802bf9:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802c00:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802c03:	89 04 24             	mov    %eax,(%esp)
  802c06:	e8 75 ec ff ff       	call   801880 <fd2num>
}
  802c0b:	c9                   	leave  
  802c0c:	c3                   	ret    

00802c0d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  802c0d:	55                   	push   %ebp
  802c0e:	89 e5                	mov    %esp,%ebp
  802c10:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802c13:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802c16:	89 44 24 04          	mov    %eax,0x4(%esp)
  802c1a:	8b 45 08             	mov    0x8(%ebp),%eax
  802c1d:	89 04 24             	mov    %eax,(%esp)
  802c20:	e8 f8 ec ff ff       	call   80191d <fd_lookup>
  802c25:	85 c0                	test   %eax,%eax
  802c27:	78 11                	js     802c3a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802c29:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802c2c:	8b 00                	mov    (%eax),%eax
  802c2e:	3b 05 58 70 80 00    	cmp    0x807058,%eax
  802c34:	0f 94 c0             	sete   %al
  802c37:	0f b6 c0             	movzbl %al,%eax
}
  802c3a:	c9                   	leave  
  802c3b:	c3                   	ret    

00802c3c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  802c3c:	55                   	push   %ebp
  802c3d:	89 e5                	mov    %esp,%ebp
  802c3f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802c42:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802c49:	00 
  802c4a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802c4d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802c51:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802c58:	e8 26 ef ff ff       	call   801b83 <read>
	if (r < 0)
  802c5d:	85 c0                	test   %eax,%eax
  802c5f:	78 0f                	js     802c70 <getchar+0x34>
		return r;
	if (r < 1)
  802c61:	85 c0                	test   %eax,%eax
  802c63:	7f 07                	jg     802c6c <getchar+0x30>
  802c65:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  802c6a:	eb 04                	jmp    802c70 <getchar+0x34>
		return -E_EOF;
	return c;
  802c6c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802c70:	c9                   	leave  
  802c71:	c3                   	ret    
	...

00802c74 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802c74:	55                   	push   %ebp
  802c75:	89 e5                	mov    %esp,%ebp
  802c77:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  802c7a:	83 3d 88 74 80 00 00 	cmpl   $0x0,0x807488
  802c81:	75 55                	jne    802cd8 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  802c83:	e8 61 e7 ff ff       	call   8013e9 <sys_getenvid>
  802c88:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802c8f:	00 
  802c90:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  802c97:	ee 
  802c98:	89 04 24             	mov    %eax,(%esp)
  802c9b:	e8 b6 e6 ff ff       	call   801356 <sys_page_alloc>
  802ca0:	85 c0                	test   %eax,%eax
  802ca2:	74 1c                	je     802cc0 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  802ca4:	c7 44 24 08 f8 38 80 	movl   $0x8038f8,0x8(%esp)
  802cab:	00 
  802cac:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  802cb3:	00 
  802cb4:	c7 04 24 1c 39 80 00 	movl   $0x80391c,(%esp)
  802cbb:	e8 ac d7 ff ff       	call   80046c <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  802cc0:	a1 80 74 80 00       	mov    0x807480,%eax
  802cc5:	8b 40 4c             	mov    0x4c(%eax),%eax
  802cc8:	c7 44 24 04 e4 2c 80 	movl   $0x802ce4,0x4(%esp)
  802ccf:	00 
  802cd0:	89 04 24             	mov    %eax,(%esp)
  802cd3:	e8 a8 e4 ff ff       	call   801180 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802cd8:	8b 45 08             	mov    0x8(%ebp),%eax
  802cdb:	a3 88 74 80 00       	mov    %eax,0x807488
}
  802ce0:	c9                   	leave  
  802ce1:	c3                   	ret    
	...

00802ce4 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  802ce4:	54                   	push   %esp
	movl _pgfault_handler, %eax
  802ce5:	a1 88 74 80 00       	mov    0x807488,%eax
	call *%eax
  802cea:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802cec:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  802cef:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  802cf4:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  802cf8:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  802cfc:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  802cfe:	83 c4 08             	add    $0x8,%esp
    popal
  802d01:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  802d02:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  802d06:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  802d07:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  802d0b:	c3                   	ret    
  802d0c:	00 00                	add    %al,(%eax)
	...

00802d10 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802d10:	55                   	push   %ebp
  802d11:	89 e5                	mov    %esp,%ebp
  802d13:	57                   	push   %edi
  802d14:	56                   	push   %esi
  802d15:	53                   	push   %ebx
  802d16:	83 ec 2c             	sub    $0x2c,%esp
  802d19:	8b 75 08             	mov    0x8(%ebp),%esi
  802d1c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802d1f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802d22:	85 db                	test   %ebx,%ebx
  802d24:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802d29:	0f 45 c3             	cmovne %ebx,%eax
  802d2c:	8b 55 14             	mov    0x14(%ebp),%edx
  802d2f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802d33:	89 44 24 08          	mov    %eax,0x8(%esp)
  802d37:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802d3b:	89 34 24             	mov    %esi,(%esp)
  802d3e:	e8 dd e3 ff ff       	call   801120 <sys_ipc_try_send>
  802d43:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802d46:	75 0a                	jne    802d52 <ipc_send+0x42>
      sys_yield();
  802d48:	e8 68 e6 ff ff       	call   8013b5 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  802d4d:	8d 76 00             	lea    0x0(%esi),%esi
  802d50:	eb d0                	jmp    802d22 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802d52:	85 c0                	test   %eax,%eax
  802d54:	79 24                	jns    802d7a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802d56:	89 44 24 10          	mov    %eax,0x10(%esp)
  802d5a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  802d5e:	c7 44 24 08 2c 39 80 	movl   $0x80392c,0x8(%esp)
  802d65:	00 
  802d66:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  802d6d:	00 
  802d6e:	c7 04 24 50 39 80 00 	movl   $0x803950,(%esp)
  802d75:	e8 f2 d6 ff ff       	call   80046c <_panic>
    else
      return;
  }
}
  802d7a:	83 c4 2c             	add    $0x2c,%esp
  802d7d:	5b                   	pop    %ebx
  802d7e:	5e                   	pop    %esi
  802d7f:	5f                   	pop    %edi
  802d80:	5d                   	pop    %ebp
  802d81:	c3                   	ret    

00802d82 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802d82:	55                   	push   %ebp
  802d83:	89 e5                	mov    %esp,%ebp
  802d85:	56                   	push   %esi
  802d86:	53                   	push   %ebx
  802d87:	83 ec 10             	sub    $0x10,%esp
  802d8a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  802d8d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802d90:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802d93:	85 c0                	test   %eax,%eax
  802d95:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  802d9a:	0f 44 c2             	cmove  %edx,%eax
  802d9d:	89 04 24             	mov    %eax,(%esp)
  802da0:	e8 1e e3 ff ff       	call   8010c3 <sys_ipc_recv>
  802da5:	85 c0                	test   %eax,%eax
  802da7:	78 24                	js     802dcd <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802da9:	85 db                	test   %ebx,%ebx
  802dab:	74 0a                	je     802db7 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  802dad:	a1 80 74 80 00       	mov    0x807480,%eax
  802db2:	8b 40 74             	mov    0x74(%eax),%eax
  802db5:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802db7:	85 f6                	test   %esi,%esi
  802db9:	74 0a                	je     802dc5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  802dbb:	a1 80 74 80 00       	mov    0x807480,%eax
  802dc0:	8b 40 78             	mov    0x78(%eax),%eax
  802dc3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  802dc5:	a1 80 74 80 00       	mov    0x807480,%eax
  802dca:	8b 40 70             	mov    0x70(%eax),%eax
}
  802dcd:	83 c4 10             	add    $0x10,%esp
  802dd0:	5b                   	pop    %ebx
  802dd1:	5e                   	pop    %esi
  802dd2:	5d                   	pop    %ebp
  802dd3:	c3                   	ret    

00802dd4 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802dd4:	55                   	push   %ebp
  802dd5:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802dd7:	8b 45 08             	mov    0x8(%ebp),%eax
  802dda:	89 c2                	mov    %eax,%edx
  802ddc:	c1 ea 16             	shr    $0x16,%edx
  802ddf:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802de6:	f6 c2 01             	test   $0x1,%dl
  802de9:	74 26                	je     802e11 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  802deb:	c1 e8 0c             	shr    $0xc,%eax
  802dee:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802df5:	a8 01                	test   $0x1,%al
  802df7:	74 18                	je     802e11 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802df9:	c1 e8 0c             	shr    $0xc,%eax
  802dfc:	8d 14 40             	lea    (%eax,%eax,2),%edx
  802dff:	c1 e2 02             	shl    $0x2,%edx
  802e02:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802e07:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  802e0c:	0f b7 c0             	movzwl %ax,%eax
  802e0f:	eb 05                	jmp    802e16 <pageref+0x42>
  802e11:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802e16:	5d                   	pop    %ebp
  802e17:	c3                   	ret    
	...

00802e20 <__udivdi3>:
  802e20:	55                   	push   %ebp
  802e21:	89 e5                	mov    %esp,%ebp
  802e23:	57                   	push   %edi
  802e24:	56                   	push   %esi
  802e25:	83 ec 10             	sub    $0x10,%esp
  802e28:	8b 45 14             	mov    0x14(%ebp),%eax
  802e2b:	8b 55 08             	mov    0x8(%ebp),%edx
  802e2e:	8b 75 10             	mov    0x10(%ebp),%esi
  802e31:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802e34:	85 c0                	test   %eax,%eax
  802e36:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802e39:	75 35                	jne    802e70 <__udivdi3+0x50>
  802e3b:	39 fe                	cmp    %edi,%esi
  802e3d:	77 61                	ja     802ea0 <__udivdi3+0x80>
  802e3f:	85 f6                	test   %esi,%esi
  802e41:	75 0b                	jne    802e4e <__udivdi3+0x2e>
  802e43:	b8 01 00 00 00       	mov    $0x1,%eax
  802e48:	31 d2                	xor    %edx,%edx
  802e4a:	f7 f6                	div    %esi
  802e4c:	89 c6                	mov    %eax,%esi
  802e4e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802e51:	31 d2                	xor    %edx,%edx
  802e53:	89 f8                	mov    %edi,%eax
  802e55:	f7 f6                	div    %esi
  802e57:	89 c7                	mov    %eax,%edi
  802e59:	89 c8                	mov    %ecx,%eax
  802e5b:	f7 f6                	div    %esi
  802e5d:	89 c1                	mov    %eax,%ecx
  802e5f:	89 fa                	mov    %edi,%edx
  802e61:	89 c8                	mov    %ecx,%eax
  802e63:	83 c4 10             	add    $0x10,%esp
  802e66:	5e                   	pop    %esi
  802e67:	5f                   	pop    %edi
  802e68:	5d                   	pop    %ebp
  802e69:	c3                   	ret    
  802e6a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802e70:	39 f8                	cmp    %edi,%eax
  802e72:	77 1c                	ja     802e90 <__udivdi3+0x70>
  802e74:	0f bd d0             	bsr    %eax,%edx
  802e77:	83 f2 1f             	xor    $0x1f,%edx
  802e7a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802e7d:	75 39                	jne    802eb8 <__udivdi3+0x98>
  802e7f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802e82:	0f 86 a0 00 00 00    	jbe    802f28 <__udivdi3+0x108>
  802e88:	39 f8                	cmp    %edi,%eax
  802e8a:	0f 82 98 00 00 00    	jb     802f28 <__udivdi3+0x108>
  802e90:	31 ff                	xor    %edi,%edi
  802e92:	31 c9                	xor    %ecx,%ecx
  802e94:	89 c8                	mov    %ecx,%eax
  802e96:	89 fa                	mov    %edi,%edx
  802e98:	83 c4 10             	add    $0x10,%esp
  802e9b:	5e                   	pop    %esi
  802e9c:	5f                   	pop    %edi
  802e9d:	5d                   	pop    %ebp
  802e9e:	c3                   	ret    
  802e9f:	90                   	nop
  802ea0:	89 d1                	mov    %edx,%ecx
  802ea2:	89 fa                	mov    %edi,%edx
  802ea4:	89 c8                	mov    %ecx,%eax
  802ea6:	31 ff                	xor    %edi,%edi
  802ea8:	f7 f6                	div    %esi
  802eaa:	89 c1                	mov    %eax,%ecx
  802eac:	89 fa                	mov    %edi,%edx
  802eae:	89 c8                	mov    %ecx,%eax
  802eb0:	83 c4 10             	add    $0x10,%esp
  802eb3:	5e                   	pop    %esi
  802eb4:	5f                   	pop    %edi
  802eb5:	5d                   	pop    %ebp
  802eb6:	c3                   	ret    
  802eb7:	90                   	nop
  802eb8:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ebc:	89 f2                	mov    %esi,%edx
  802ebe:	d3 e0                	shl    %cl,%eax
  802ec0:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802ec3:	b8 20 00 00 00       	mov    $0x20,%eax
  802ec8:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802ecb:	89 c1                	mov    %eax,%ecx
  802ecd:	d3 ea                	shr    %cl,%edx
  802ecf:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ed3:	0b 55 ec             	or     -0x14(%ebp),%edx
  802ed6:	d3 e6                	shl    %cl,%esi
  802ed8:	89 c1                	mov    %eax,%ecx
  802eda:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802edd:	89 fe                	mov    %edi,%esi
  802edf:	d3 ee                	shr    %cl,%esi
  802ee1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ee5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802ee8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802eeb:	d3 e7                	shl    %cl,%edi
  802eed:	89 c1                	mov    %eax,%ecx
  802eef:	d3 ea                	shr    %cl,%edx
  802ef1:	09 d7                	or     %edx,%edi
  802ef3:	89 f2                	mov    %esi,%edx
  802ef5:	89 f8                	mov    %edi,%eax
  802ef7:	f7 75 ec             	divl   -0x14(%ebp)
  802efa:	89 d6                	mov    %edx,%esi
  802efc:	89 c7                	mov    %eax,%edi
  802efe:	f7 65 e8             	mull   -0x18(%ebp)
  802f01:	39 d6                	cmp    %edx,%esi
  802f03:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802f06:	72 30                	jb     802f38 <__udivdi3+0x118>
  802f08:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802f0b:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802f0f:	d3 e2                	shl    %cl,%edx
  802f11:	39 c2                	cmp    %eax,%edx
  802f13:	73 05                	jae    802f1a <__udivdi3+0xfa>
  802f15:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802f18:	74 1e                	je     802f38 <__udivdi3+0x118>
  802f1a:	89 f9                	mov    %edi,%ecx
  802f1c:	31 ff                	xor    %edi,%edi
  802f1e:	e9 71 ff ff ff       	jmp    802e94 <__udivdi3+0x74>
  802f23:	90                   	nop
  802f24:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802f28:	31 ff                	xor    %edi,%edi
  802f2a:	b9 01 00 00 00       	mov    $0x1,%ecx
  802f2f:	e9 60 ff ff ff       	jmp    802e94 <__udivdi3+0x74>
  802f34:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802f38:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802f3b:	31 ff                	xor    %edi,%edi
  802f3d:	89 c8                	mov    %ecx,%eax
  802f3f:	89 fa                	mov    %edi,%edx
  802f41:	83 c4 10             	add    $0x10,%esp
  802f44:	5e                   	pop    %esi
  802f45:	5f                   	pop    %edi
  802f46:	5d                   	pop    %ebp
  802f47:	c3                   	ret    
	...

00802f50 <__umoddi3>:
  802f50:	55                   	push   %ebp
  802f51:	89 e5                	mov    %esp,%ebp
  802f53:	57                   	push   %edi
  802f54:	56                   	push   %esi
  802f55:	83 ec 20             	sub    $0x20,%esp
  802f58:	8b 55 14             	mov    0x14(%ebp),%edx
  802f5b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802f5e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802f61:	8b 75 0c             	mov    0xc(%ebp),%esi
  802f64:	85 d2                	test   %edx,%edx
  802f66:	89 c8                	mov    %ecx,%eax
  802f68:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802f6b:	75 13                	jne    802f80 <__umoddi3+0x30>
  802f6d:	39 f7                	cmp    %esi,%edi
  802f6f:	76 3f                	jbe    802fb0 <__umoddi3+0x60>
  802f71:	89 f2                	mov    %esi,%edx
  802f73:	f7 f7                	div    %edi
  802f75:	89 d0                	mov    %edx,%eax
  802f77:	31 d2                	xor    %edx,%edx
  802f79:	83 c4 20             	add    $0x20,%esp
  802f7c:	5e                   	pop    %esi
  802f7d:	5f                   	pop    %edi
  802f7e:	5d                   	pop    %ebp
  802f7f:	c3                   	ret    
  802f80:	39 f2                	cmp    %esi,%edx
  802f82:	77 4c                	ja     802fd0 <__umoddi3+0x80>
  802f84:	0f bd ca             	bsr    %edx,%ecx
  802f87:	83 f1 1f             	xor    $0x1f,%ecx
  802f8a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802f8d:	75 51                	jne    802fe0 <__umoddi3+0x90>
  802f8f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802f92:	0f 87 e0 00 00 00    	ja     803078 <__umoddi3+0x128>
  802f98:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802f9b:	29 f8                	sub    %edi,%eax
  802f9d:	19 d6                	sbb    %edx,%esi
  802f9f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802fa2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802fa5:	89 f2                	mov    %esi,%edx
  802fa7:	83 c4 20             	add    $0x20,%esp
  802faa:	5e                   	pop    %esi
  802fab:	5f                   	pop    %edi
  802fac:	5d                   	pop    %ebp
  802fad:	c3                   	ret    
  802fae:	66 90                	xchg   %ax,%ax
  802fb0:	85 ff                	test   %edi,%edi
  802fb2:	75 0b                	jne    802fbf <__umoddi3+0x6f>
  802fb4:	b8 01 00 00 00       	mov    $0x1,%eax
  802fb9:	31 d2                	xor    %edx,%edx
  802fbb:	f7 f7                	div    %edi
  802fbd:	89 c7                	mov    %eax,%edi
  802fbf:	89 f0                	mov    %esi,%eax
  802fc1:	31 d2                	xor    %edx,%edx
  802fc3:	f7 f7                	div    %edi
  802fc5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802fc8:	f7 f7                	div    %edi
  802fca:	eb a9                	jmp    802f75 <__umoddi3+0x25>
  802fcc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802fd0:	89 c8                	mov    %ecx,%eax
  802fd2:	89 f2                	mov    %esi,%edx
  802fd4:	83 c4 20             	add    $0x20,%esp
  802fd7:	5e                   	pop    %esi
  802fd8:	5f                   	pop    %edi
  802fd9:	5d                   	pop    %ebp
  802fda:	c3                   	ret    
  802fdb:	90                   	nop
  802fdc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802fe0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802fe4:	d3 e2                	shl    %cl,%edx
  802fe6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802fe9:	ba 20 00 00 00       	mov    $0x20,%edx
  802fee:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802ff1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802ff4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ff8:	89 fa                	mov    %edi,%edx
  802ffa:	d3 ea                	shr    %cl,%edx
  802ffc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803000:	0b 55 f4             	or     -0xc(%ebp),%edx
  803003:	d3 e7                	shl    %cl,%edi
  803005:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803009:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80300c:	89 f2                	mov    %esi,%edx
  80300e:	89 7d e8             	mov    %edi,-0x18(%ebp)
  803011:	89 c7                	mov    %eax,%edi
  803013:	d3 ea                	shr    %cl,%edx
  803015:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803019:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80301c:	89 c2                	mov    %eax,%edx
  80301e:	d3 e6                	shl    %cl,%esi
  803020:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803024:	d3 ea                	shr    %cl,%edx
  803026:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80302a:	09 d6                	or     %edx,%esi
  80302c:	89 f0                	mov    %esi,%eax
  80302e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  803031:	d3 e7                	shl    %cl,%edi
  803033:	89 f2                	mov    %esi,%edx
  803035:	f7 75 f4             	divl   -0xc(%ebp)
  803038:	89 d6                	mov    %edx,%esi
  80303a:	f7 65 e8             	mull   -0x18(%ebp)
  80303d:	39 d6                	cmp    %edx,%esi
  80303f:	72 2b                	jb     80306c <__umoddi3+0x11c>
  803041:	39 c7                	cmp    %eax,%edi
  803043:	72 23                	jb     803068 <__umoddi3+0x118>
  803045:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803049:	29 c7                	sub    %eax,%edi
  80304b:	19 d6                	sbb    %edx,%esi
  80304d:	89 f0                	mov    %esi,%eax
  80304f:	89 f2                	mov    %esi,%edx
  803051:	d3 ef                	shr    %cl,%edi
  803053:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803057:	d3 e0                	shl    %cl,%eax
  803059:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80305d:	09 f8                	or     %edi,%eax
  80305f:	d3 ea                	shr    %cl,%edx
  803061:	83 c4 20             	add    $0x20,%esp
  803064:	5e                   	pop    %esi
  803065:	5f                   	pop    %edi
  803066:	5d                   	pop    %ebp
  803067:	c3                   	ret    
  803068:	39 d6                	cmp    %edx,%esi
  80306a:	75 d9                	jne    803045 <__umoddi3+0xf5>
  80306c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  80306f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  803072:	eb d1                	jmp    803045 <__umoddi3+0xf5>
  803074:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803078:	39 f2                	cmp    %esi,%edx
  80307a:	0f 82 18 ff ff ff    	jb     802f98 <__umoddi3+0x48>
  803080:	e9 1d ff ff ff       	jmp    802fa2 <__umoddi3+0x52>
